@{
var asyncSettings = new Syncfusion.EJ2.Inputs.UploaderAsyncSettings { SaveUrl = "https://localhost:44362/Home/Save/", RemoveUrl = "https://localhost:44362/Home/Remove" };
}
<ejs-uploader id="UploadFiles" asyncSettings="@asyncSettings">
</ejs-uploader>
<form action="https://localhost:44362/Home/BlogSave" method="post">
<ejs-uploader id="UploadFiles1"></ejs-uploader>
<input type="submit" value="Upload" class="e-btn" />
</form> |
Use PNG transparent logo file.
Use JPG image file.
@{
var asyncSettings = new Syncfusion.EJ2.Inputs.UploaderAsyncSettings { SaveUrl = "https://localhost:44362/Home/Save/", RemoveUrl = "https://localhost:44362/Home/Remove" };
}
@{
var asyncSettings1 = new Syncfusion.EJ2.Inputs.UploaderAsyncSettings { SaveUrl = "https://localhost:44362/Home/BlogSave/", RemoveUrl = "https://localhost:44362/Home/BlogRemove" };
}
<ejs-uploader id="UploadFiles" asyncSettings="@asyncSettings">
</ejs-uploader>
<ejs-uploader id="uploadFiles2" asyncSettings="@asyncSettings1">
</ejs-uploader> |
public IActionResult Save(IList<IFormFile> UploadFiles)
{
try
{
…
}
public IActionResult BlogSave(IList<IFormFile> uploadFiles2)
{
Try
…
} |
public static byte[] content = new byte[] { };
public async Task Save(IList<IFormFile> chunkFile, IList<IFormFile> uploadFiles)
{
try
{
foreach (var file in chunkFile)
{
var httpPostedChunkFile = HttpContext.Request.Form.Files["chunkFile"];
var chunkIndex = HttpContext.Request.Form["chunk-index"];
var totalChunk = HttpContext.Request.Form["total-chunk"];
using (var fileStream = file.OpenReadStream())
{
if (Convert.ToInt32(chunkIndex) <= Convert.ToInt32(totalChunk))
{
var streamReader = new MemoryStream();
fileStream.CopyTo(streamReader);
var byteArr = streamReader.ToArray();
if (content.Length > 0)
{
content = content.Concat(byteArr).ToArray();
}
else
{
content = byteArr;
}
}
if (Convert.ToInt32(chunkIndex) == Convert.ToInt32(totalChunk) - 1)
{
const string accountName = "****"; // Provide the account name
const string key = "****"; // Provide the account key
var storageCredentials = new StorageCredentials(accountName, key);
var cloudStorageAccount = new CloudStorageAccount(storageCredentials, true);
var cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
var container = cloudBlobClient.GetContainerReference("filo");
CloudBlockBlob blockBlob = container.GetBlockBlobReference(httpPostedChunkFile.FileName);
using (FileStream fileStreams = new FileStream(httpPostedChunkFile.FileName, FileMode.Create))
{
for (int i = 0; i < content.Length; i++)
{
fileStreams.WriteByte(content[i]);
}
fileStreams.Seek(0, SeekOrigin.Begin);
content = new byte[] { };
await blockBlob.UploadFromStreamAsync(fileStreams);
}
}
}
}
}
catch (Exception e)
{
content = new byte[] { };
Response.Clear();
Response.StatusCode = 204;
Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = "File failed to upload";
Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = e.Message;
}
}
} |