public FineUploaderResult UploadFile(FineUpload upload) { // asp.net mvc will set extraParam1 and extraParam2 from the params object passed by Fine-Uploader try { string fileName = null; string filedir = Request.QueryString["action"]; if (string.IsNullOrEmpty(filedir)) { filedir = "DefaultFile"; } string tempDir = DateTime.Now.ToString("yyyyMMddHHmmssfff"); string dir = Path.Combine(Request.PhysicalApplicationPath, "Upload", filedir, tempDir); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } fileName = Path.GetFileName(upload.Filename); upload.SaveAs(Path.Combine(dir, fileName)); return new FineUploaderResult(true, new { success = "true", filePath = "/Upload/" + filedir + "/" + tempDir + "/" + fileName, fileName = fileName }); } catch (Exception ex) { return new FineUploaderResult(false, error: ex.Message); } }
public FineUploaderResult UploadPdf(FineUpload upload) { try { string fileName = null; string filedir = Request.QueryString["action"]; if (string.IsNullOrEmpty(filedir)) { filedir = "DefaultFile"; } string tempDir = DateTime.Now.ToString("yyyyMMddHHmmssfff"); string dir = Path.Combine(Request.PhysicalApplicationPath, "Upload", filedir, tempDir); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } fileName = Path.GetFileName(upload.Filename); upload.SaveAs(Path.Combine(dir, fileName)); var absPath = "/Upload/" + filedir + "/" + tempDir + "/" + fileName; SwftoolsHelp.PDF2Swf(absPath, absPath + ".swf"); return new FineUploaderResult(true, new { success = "true", filePath = absPath, fileName = fileName }); } catch (Exception ex) { return new FineUploaderResult(false, error: ex.Message); } }
public FineUploaderResult UploadPdf(FineUpload upload) { try { string fileName = null; string filedir = Request.QueryString["action"]; if (string.IsNullOrEmpty(filedir)) { filedir = "DefaultFile"; } string tempDir = DateTime.Now.ToString("yyyyMMddHHmmssfff"); string dir = Path.Combine(Request.PhysicalApplicationPath, "Upload", filedir, tempDir); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } fileName = Path.GetFileName(upload.Filename); upload.SaveAs(Path.Combine(dir, fileName)); var absPath = "/Upload/" + filedir + "/" + tempDir + "/" + fileName; SwftoolsHelp.PDF2Swf(absPath, absPath + ".swf"); return(new FineUploaderResult(true, new { success = "true", filePath = absPath, fileName = fileName })); } catch (Exception ex) { return(new FineUploaderResult(false, error: ex.Message)); } }
public FineUploaderResult UploadFile(FineUpload upload) { // asp.net mvc will set extraParam1 and extraParam2 from the params object passed by Fine-Uploader try { string fileName = null; string filedir = Request.QueryString["action"]; if (string.IsNullOrEmpty(filedir)) { filedir = "DefaultFile"; } string tempDir = DateTime.Now.ToString("yyyyMMddHHmmssfff"); string dir = Path.Combine(Request.PhysicalApplicationPath, "Upload", filedir, tempDir); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } fileName = Path.GetFileName(upload.Filename); upload.SaveAs(Path.Combine(dir, fileName)); return(new FineUploaderResult(true, new { success = "true", filePath = "/Upload/" + filedir + "/" + tempDir + "/" + fileName, fileName = fileName })); } catch (Exception ex) { return(new FineUploaderResult(false, error: ex.Message)); } }
public Task BindModelAsync(ModelBindingContext bindingContext) { var _request = bindingContext.HttpContext.Request; var _files = _request.Form.Files; var formUpload = _files.Count > 0; // find filename string xFileName = _request.Headers["X-File-Name"]; string qqFile = _request.Form["qqfilename"]; var formFilename = formUpload ? Path.GetFileName(_files[0].FileName) : null; var upload = new FineUpload(_uploadDirectory) { UploadId = new Guid(_request.Form["uploadID"]), Filename = xFileName ?? qqFile ?? formFilename, InputStream = formUpload ? _files[0].OpenReadStream() : _request.Body, TotalFileSize = Convert.ToInt64(_request.Form["qqtotalfilesize"].ToString()), PartIndex = Convert.ToInt32(_request.Form["qqpartindex"]), TotalParts = Convert.ToInt32(_request.Form["qqtotalparts"]), PartByteOffSet = Convert.ToInt64(_request.Form["qqpartbyteoffset"]), ChunkSize = Convert.ToInt32(_request.Form["qqchunksize"]), UUI = new Guid(_request.Form["qquuid"].ToString()), JoinFiles = !formUpload }; bindingContext.Result = ModelBindingResult.Success(upload); return(Task.CompletedTask); }
public FineUploaderResult UploadFile(FineUpload upload, string extraParam1, int extraParam2) { // asp.net mvc will set extraParam1 and extraParam2 from the params object passed by Fine-Uploader var dir = @"c:\upload\path"; var filePath = Path.Combine(dir, upload.Filename); try { upload.SaveAs(filePath); } catch (Exception ex) { return new FineUploaderResult(false, error: ex.Message); } // the anonymous object in the result below will be convert to json and set back to the browser return new FineUploaderResult(true, new { extraInformation = 12345 }); }
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { var request = controllerContext.RequestContext.HttpContext.Request; var formUpload = request.Files.Count > 0; // find filename var xFileName = request.Headers["X-File-Name"]; var qqFile = request["qqfile"]; var formFilename = formUpload ? request.Files[0].FileName : null; var upload = new FineUpload { Filename = xFileName ?? qqFile ?? formFilename, InputStream = formUpload ? request.Files[0].InputStream : request.InputStream }; return(upload); }
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { var request = controllerContext.RequestContext.HttpContext.Request; var formUpload = request.Files.Count > 0; // find filename var xFileName = request.Headers["X-File-Name"]; var qqFile = request["qqfile"]; var formFilename = formUpload ? request.Files[0].FileName : null; var upload = new FineUpload { Filename = xFileName ?? qqFile ?? formFilename, InputStream = formUpload ? request.Files[0].InputStream : request.InputStream }; return upload; }
public FineUploaderResult UploadFile(FineUpload upload) { var dir = HttpContext.Server.MapPath("~/App_Data"); var fileName = Guid.NewGuid().ToString("N"); var filePath = Path.Combine(dir, fileName); try { var image = Image.FromStream(upload.InputStream); image.Save(filePath, ImageFormat.Png); } catch (Exception ex) { return new FineUploaderResult(false, error: ex.Message); } return new FineUploaderResult(true, new { fileName = fileName }); }
public FineUploaderResult UploadFile(FineUpload upload, string extraParam1, int extraParam2) { // asp.net mvc will set extraParam1 and extraParam2 from the params object passed by Fine-Uploader var dir = @"c:\upload\path"; var filePath = Path.Combine(dir, upload.Filename); try { upload.SaveAs(filePath); } catch (Exception ex) { return(new FineUploaderResult(false, error: ex.Message)); } // the anonymous object in the result below will be convert to json and set back to the browser return(new FineUploaderResult(true, new { extraInformation = 12345 })); }
public FineUploaderResult UploadFile(FineUpload upload, string extraParam1 = null, int extraParam2 = 0) { // asp.net mvc will set extraParam1 and extraParam2 from the params object passed by Fine-Uploader var dir = Server.MapPath(Constant.UPLOADED_FILES_DIRECTORY); var filePath = Path.Combine(dir, upload.Filename); try { upload.SaveAs(filePath); return(new FineUploaderResult(true, new { FilePath = filePath })); } catch (Exception ex) { return(new FineUploaderResult(false, error: ex.Message)); } // the anonymous object in the result below will be convert to json and set back to the browser //return new FineUploaderResult(true, new { extraInformation = 12345 }); }