<link href="~/Content/fineuploader-3.5.0.css" rel="stylesheet" >
<script src="~/Scripts/fineuploader-3.5.0.js"><script>
<div id="fine-uploader"><div>
<script>
function createUploader() {
var uploader = new qq.FineUploader({
element: document.getElementById('fine-uploader'),
request: {
endpoint: '@Url.Action("UploadBatchDataFile")'
}
});
}
window.onload = createUploader;
<script>
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UploadBatchDataFile(HttpPostedFileBase qqfile)
{
if (qqfile != null && qqfile.ContentLength > 0)
{
string fileName = Guid.NewGuid().ToString() + Path.GetExtension(qqfile.FileName);
var path = Path.Combine(Server.MapPath("~/App_Data/BatchData"), fileName);
qqfile.SaveAs(@path);
// further processing on file can be done here
return Json(new { success = true });
}
else
{
// this works for Firefox, Chrome
var filename = Request["qqfile"];
if (!string.IsNullOrEmpty(filename))
{
string newFileName = Guid.NewGuid().ToString() + Path.GetExtension(qqfile.FileName);
filename = Path.Combine(Server.MapPath("~/App_Data/BatchData"), newFileName);
using (var output = File.Create(filename))
{
Request.InputStream.CopyTo(output);
}
// further processing on file can be done here
return Json(new { success = true });
}
}
return Json(new { success = false });
}
Share this page on
25
People Like(s) This Page
Permalink
comments powered by Disqus