/// <summary> /// Create a new DroppedFile object. /// </summary> /// <param name="id">Initial value of the id property.</param> public static DroppedFile CreateDroppedFile(global::System.Int32 id) { DroppedFile droppedFile = new DroppedFile(); droppedFile.id = id; return(droppedFile); }
public ActionResult Upload() { ContentResult c = new ContentResult(); if (Request.Form["value"] != null && Request.Form["name"] != null) { try { //TODO: change file name to (G|U)UID perhaps? string b64_data = (Request.Form["value"].Split(',')[1]).Replace(' ', '+'); string baseDir = Path.Combine(Server.MapPath("/"), this._imageDirectoryPrefix); string fileName = Path.GetFileName(Request.Form["name"]); string path = baseDir + fileName; //check if dir exists, if not: make it if (!System.IO.File.Exists(baseDir)) System.IO.Directory.CreateDirectory(baseDir); System.IO.File.WriteAllBytes(path, Convert.FromBase64String(b64_data)); // now create model DroppedFile d = new DroppedFile() { FName = fileName, DateCreated = DateTime.Now }; _fileDropEntities.DroppedFiles.AddObject(d); _fileDropEntities.SaveChanges(); c.Content = fileName + ":uploaded successfully:" + d.id; } catch (Exception e) { c.Content = "-1"; } } else c.Content = "-1"; return c; }
/// <summary> /// Deprecated Method for adding a new object to the DroppedFiles EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDroppedFiles(DroppedFile droppedFile) { base.AddObject("DroppedFiles", droppedFile); }
/// <summary> /// Create a new DroppedFile object. /// </summary> /// <param name="id">Initial value of the id property.</param> public static DroppedFile CreateDroppedFile(global::System.Int32 id) { DroppedFile droppedFile = new DroppedFile(); droppedFile.id = id; return droppedFile; }