Of course, this plugin is only for the file upload, and not the data along with it.
Quote:
The jQuery File Upload Plugin consists of a basic version (jquery.fileupload.js) providing the File Upload API.
It's okay but why to go for 3rd party solution when
HTML5
provides the file input ?
<input type="file" id="fileUpload" name="fileUpload" />
Here,
type="file"
, defines a file-select field and a "Browse..." button (for file uploads).
Now let's make a demo.
HTML:
<!--
<form id="myForm" action="@Url.Action('UploadAction1', 'Media')" enctype="multipart/form-data">
@Html.TextBoxFor(m => m.Name)
<input type="file" id="fileUpload" name="fileUpload" />
</form>
Now the
jQuery,
$("#fileUpload").change(function() {
$("#myForm").submit();
});
You can refer this
documentation [
^] for showing the file upload progress.
And finally the
Action Method
[HttpPost]
public ActionResult UploadAction1()
{
if (Request.Files.Count > 0)
{
var file = Request.Files[0];
if (file != null && file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/Images/"), fileName);
file.SaveAs(path);
}
}
return RedirectToAction("Index");
}
-KR