protected void Submit1_ServerClick(object sender, System.EventArgs e) { if ((File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0)) { try { byte[] songData = null; using (var binaryReader = new System.IO.BinaryReader(File1.PostedFile.InputStream)) { songData = binaryReader.ReadBytes(File1.PostedFile.ContentLength); } if (System.IO.Path.GetExtension(File1.PostedFile.FileName) == ".txt") { ServiceAccessor.UploadSong(songData); } else { ServiceAccessor.UploadMultipleSongs(songData); } succ_msg.Attributes.Remove("hidden"); } catch (Exception ex) { err_msg.Attributes.Remove("hidden"); } } else { warn_msg.Attributes.Remove("hidden"); } }
public static object UploadFile() { //HttpContext.Current.Request.Files; byte[] songData = null; HttpPostedFile songFile = HttpContext.Current.Request.Files[0]; using (var binaryReader = new System.IO.BinaryReader(songFile.InputStream)) { songData = binaryReader.ReadBytes(songFile.ContentLength); } return(ServiceAccessor.UploadSong(songData)); }