BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
Hi Andrew,
Thanks for using Syncfusion Products.
We have provided the sample code for achieving the synchronous upload option of Uploadbox using ASP.NET MVC application.
For Synchronous Upload,
1. We have created the submit button, reset button and the target <div> element for Uploadbox inside the Html.BeginForm.
[View Page cshtml]
@using (Html.BeginForm("Index", "upload", FormMethod.Post, new { id = "uploadForm", enctype = "multipart/form-data" }))
{
<div id="syncupload"></div>
<input type="submit" class="inputbutton" value="Upload" />
<input type="reset" class="inputbutton" value="Reset" />
}
2. We have initialized the ejUploadbox with asyncUpload api set to false.
[Script]
<script type="text/javascript">
$(function () {
$('#syncupload').ejUploadbox({ asyncUpload: false });
});
</script>
We have provided the sample server side code for processing the form submit action.
[Controller c#]
public ActionResult Index()
{
return View();
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(IEnumerable<HttpPostedFileBase> syncupload)
{
if (syncupload != null)
foreach (var file in syncupload)
{
if (file != null)
{
var fileName = Path.GetFileName(file.FileName);
var destinationPath = Path.Combine(Server.MapPath("~/App_Data"), fileName);
file.SaveAs(destinationPath);
return View("UploadSuccess");
}
}
return View();
}
public ActionResult UploadSuccess()
{
return View();
}
Please let us know if this helps.
Thanks/Regards,
John Arokyaraj.V
Hi Andrew,
Thanks for your update. We appreciate the opportunity to assist you.
Thanks/Regards,
John Arokyaraj.V
protected void btnUploadClick(object sender, EventArgs e)
{
string fname;
HttpFileCollection hfc = Request.Files;
for (int i = 0; i <= hfc.Count - 1; i++)
{
HttpPostedFile hpf = hfc[i];
if (hpf != null && hpf.ContentLength > 0)
{
fname = Path.GetFileName(hpf.FileName);
hpf.SaveAs(Server.MapPath(Path.Combine("~/upload/", fname)));
status.Text += "FileName :" + fname;
status1.Text += "FilePath : " + Server.MapPath(Path.Combine("~/upload/"));
}
}
}
</code>
For this scenario we have also attached a sample. Please find the sample below.
http://www.syncfusion.com/downloads/support/forum/121578/ze/upload-249855840
Please contact us in future if you have any queries.
Regards,
Arun P