protected void UploadButton_Click(object sender, EventArgs e) { if (FileUploadControl.HasFile) { try { if ((FileUploadControl.PostedFile.ContentType == "image/jpeg") || (FileUploadControl.PostedFile.ContentType == "image/pjpeg") || (FileUploadControl.PostedFile.ContentType == "image/png") || (FileUploadControl.PostedFile.ContentType == "image/gif")) { if (FileUploadControl.PostedFile.ContentLength < 10485760) { string filename = Path.GetFileName(FileUploadControl.FileName); FileUploadControl.SaveAs(Server.MapPath("~/Images/") + filename); databaseHelper.addProduct(txtProdName.Text, txtProdPrice.Text, txtProdIng.Text, txtProdDesc.Text, filename); StatusLabel.Text = "Upload status: Product Added!"; } else { StatusLabel.Text = "Upload status: The file has to be less than 10 mb!"; } } else { StatusLabel.Text = "Upload status: Only JPEG, GIF, and PNG files are accepted!"; } } catch (Exception ex) { StatusLabel.Text = "Upload status: The product could not be added. The following error occured: " + ex.Message; } } }
protected void btnOK_Click(object sender, EventArgs e) { try { string filename = ""; if (FileUploadControl.HasFile) { if (FileUploadControl.PostedFile.ContentType == "image/jpeg") { filename = Path.GetFileName(FileUploadControl.FileName); FileUploadControl.SaveAs(Server.MapPath("~/MemberProfilePicture/" + filename)); imgProfileImage.ImageUrl = "~/" + Server.MapPath("~/MemberProfilePicture/" + filename); } else { StatusLabel.Text = "Upload status: Only JPEG files are accepted!"; } } UpdateUser(); ClearValues(); txtSearch.Text = ""; txtSearch.Focus(); } catch (Exception ex) { throw ex; } }
private bool ManageUpload(out string error, out string fileName) { string fileExtension = Path.GetExtension(FileUploadControl.FileName).ToLower(); string[] allowedExtensions = { ".png", ".jpeg", ".jpg" }; if (!allowedExtensions.Contains(fileExtension)) { error = "File extension not allowed."; fileName = ""; return(false); } string serverPath = Server.MapPath("uploads\\"); fileName = FileUploadControl.FileName; string path = Path.Combine(serverPath, fileName); int index = 0; while (File.Exists(path)) { ++index; fileName = Path.GetFileNameWithoutExtension(fileName) + " (" + index.ToString() + ")" + fileExtension; path = Path.Combine(serverPath, fileName); } try { FileUploadControl.SaveAs(path); } catch (Exception ex) { error = ex.Message; } error = "File uploaded successfully!"; return(true); }
protected void btnupload_Click(object sender, EventArgs e) { // Image1.Visible = true; //Session["FilePath"] = FileUploadControl.FileName; string fPath = ConfigurationManager.AppSettings["EXCEL_SHEET"]; EmailSender.DAO_Message objMessage = new EmailSender.DAO_Message(); if (FileUploadControl.HasFile) { if (FileUploadControl.PostedFile.ContentLength < 10240000) { string fname = ""; fname = FileUploadControl.PostedFile.FileName; string file = ""; file = FileUploadControl.FileName; string filename = ""; filename = getFileName("Support") + file.Substring(file.IndexOf("."), (file.Length - file.IndexOf("."))); txtupload.Text = fPath + "/" + filename; FileUploadControl.SaveAs(fPath + "/" + filename); // FileUploadControl.SaveAs(fPath); lblFileName.Text = FileUploadControl.FileName; } } else { lblMsg.Text = "Please upload file of size less than 10MB"; } }
protected void submitBtn_Click(object sender, EventArgs e) { if (FileUploadControl.HasFile) { string filename; try { filename = Path.GetFileName(FileUploadControl.FileName); FileUploadControl.SaveAs(Server.MapPath("~/images/") + filename); } catch (Exception ex) { return; } newsData _data = new newsData() { Title = Title.Value.Replace(">", "").Replace("<", ""), Image = "images/" + filename, Text = Content.Value.Replace(">", "").Replace("<", "") }; DatabaseConnector.Inst.saveNewsData(Server.MapPath("~/ ") + "/json/updatableNews.json", _data, (string)Session["loggedIn"]); Response.Redirect("default.aspx"); } }
private void addTabPage(string fileName) { FileInfo file = new FileInfo(fileName); if (file.Length >= 2097152) { chatMessageViewerControl1.AddInformation("你上传的文件过大!仅限 2M"); return; } FileUploadControl fileUpload = null; if (!this.tabControlVideo.Controls.Contains(this.tabPage3)) { createTabPage(); } fileUpload = new FileUploadControl(fileName, uploadURL); fileUpload.FileUploadCompleted += new EventHandler <FileUploadEventArgs>(fileUpload_FileUploadCompleted); this.uploadTasks.Add(fileUpload.FtpUpload); this.tabPage3.Controls.Add(fileUpload); fileUpload.Dock = DockStyle.Top; }
protected void addCelebrite() { Stream fs = FileUploadControl.PostedFile.InputStream; using (BinaryReader br = new BinaryReader(fs)) { byte[] bytes = br.ReadBytes((Int32)fs.Length); using (SqlConnection con = new SqlConnection("Data Source=fp-server.database.windows.net;" + "Initial Catalog=fp-database;User ID=fp-admin;Password=Cebula1.")) { string query = "insert into CELEBRITE_ALBUM values (@id_character, @name, @surname, @image)"; using (SqlCommand cmd = new SqlCommand(query)) { cmd.Connection = con; cmd.Parameters.AddWithValue("@id_character", amount_character); cmd.Parameters.AddWithValue("@name", name.Text); cmd.Parameters.AddWithValue("@surname", surname.Text); cmd.Parameters.AddWithValue("@image", bytes); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } } bytes = null; br.Dispose(); br.Close(); } fs.Dispose(); fs.Close(); FileUploadControl.Dispose(); }
protected void UploadButton_Click(object sender, EventArgs e) { int id = Convert.ToInt32(ViewState["ID"]); if (FileUploadControl.HasFile) { try { string originalFilename = Path.GetFileName(FileUploadControl.FileName); string extension = Path.GetExtension(FileUploadControl.FileName); string filename = Guid.NewGuid().ToString(); FileUploadControl.SaveAs(Server.MapPath("~/Forwarding/Transaction/EstimateFiles/") + filename + "." + extension); hdnFileName.Value = filename; //Update file name in database JobBLL.SaveEstimateFile(id, filename, originalFilename); ClientScript.RegisterStartupScript(typeof(Page), "SymbolError", "<script type='text/javascript'>sendValue();</script>"); } catch (Exception ex) { StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message; } } }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { if (FileUploadControl.HasFile) { try { string filename = Path.GetFileName(FileUploadControl.FileName); FileUploadControl.SaveAs(Server.MapPath("~/") + filename); StatusLabel.Text = "Upload status: File uploaded!"; string toRead = Server.MapPath(FileUploadControl.FileName); StreamReader reader = File.OpenText(toRead); string line; while ((line = reader.ReadLine()) != null) { StaticSession.ws.receiveMessage(line); } reader.Close(); } catch (Exception ex) { StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message; } } } GenerateDot gen = new GenerateDot(); String s = StaticSession.ws.graphAvlTree(); gen.createDot(s, "avlTree"); s = StaticSession.ws.sendArbolB(); gen.createDot(s, "btree"); s = StaticSession.ws.sendHashGraph(); gen.createDot(s, "hashTable"); }
protected void Button1_Click1(object sender, EventArgs e) { if (FileUploadControl.HasFile) { try { filename = Path.GetFileName(FileUploadControl.FileName); FileUploadControl.SaveAs(Server.MapPath("~/") + filename); // string texto = File.ReadAllText(Server.MapPath("~/") + filename); string[] lineas = File.ReadAllLines(Server.MapPath("~/") + filename); int i = 0; while (lineas.Length > i) { TextBox1.Text = TextBox1.Text + lineas[i] + "\r\n"; //TextBox1.Text = texto + Environment.NewLine; i++; } //TextBox1.Text = texto + Environment.NewLine; } catch (Exception ex) { TextBox1.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message; } } }
/// <summary> /// do file upload,附件上传 /// </summary> private void CZ_DoFileUpLoad() { // 采用文件服务器方式进行附件存取 submitType = 1; // 检查是否启用了文件服务器 if (!Kingdee.BOS.ServiceHelper.FileServer.FileServerHelper.UsedFileServer(this.Context)) { this.View.ShowMessage("未启用文件服务器,无法实现上传。"); return; } // 取Cloud服务器配置的存储方式进行附件存储 submitType = Kingdee.BOS.ServiceHelper.FileServer.FileServerHelper.GetFileStorgaeType(this.Context); // 先将客户端附件上传至临时目录 var _BillNo = this.View.BillModel.DataObject["BillNo"]; if (_BillNo != null) { FileUploadControl _FFileUpdateCtl = null; try { _FFileUpdateCtl = this.View.GetControl <FileUploadControl>("FFileUpdate"); } catch (Exception) { } if (_FFileUpdateCtl != null) { this.View.ShowMessage("正在上传附件,请不要关闭页面!", MessageBoxOptions.OK); _FFileUpdateCtl.UploadFieldBatch(); } else { Jump2Audit(); } } }
protected void UploadButton_Click(object sender, EventArgs e) { var CaseId = Request.QueryString["CaseId"]; if (FileUploadControl.HasFile) { try { string filename = Path.GetFileName(FileUploadControl.FileName); FileUploadControl.SaveAs(Server.MapPath("~/CrimeImages/") + filename); using (OdbcConnection connection = new OdbcConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString)) { connection.Open(); string query = "insert into crimeimage values (null,'" + CaseId + "','" + filename + "')"; OdbcCommand command = new OdbcCommand(query, connection); command.ExecuteNonQuery(); connection.Close(); } ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "success();", true); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "error();", true); } } }
protected void btnUpload_Click(object sender, EventArgs e) { if (FileUploadControl.HasFile) { try { Session["FileName"] = FileUploadControl.FileName; string filename = Path.GetFileName(FileUploadControl.FileName); FileUploadControl.SaveAs(Server.MapPath("~/Resources/Import/") + filename); //Decimate Mesh funcDecimateMesh(); //Display Decimation information to client UpdateClientInformation(); //Update AssetBundle funcGenerateAssetBundle(); } catch (Exception ex) { labResultNotification.Text = "We apologize for the inconvenience it seems either the file is Corrupted or unsupported file format."; } } }
protected void UploadButton_Click(object sender, EventArgs e) { if (FileUploadControl.HasFile) { try { string filename = Path.GetFileName(FileUploadControl.FileName); FileUploadControl.SaveAs(Server.MapPath("~/") + filename); // Save a file in server. oExcel ox = new oExcel(Server.MapPath("~/") + filename); DataTable dt = ox.GetDataSQL("Select * from [Sheet1$]"); oUsers ou = new oUsers(); foreach (DataRow dr in dt.Rows) { ou.CreateUser(dr[0].ToString(), dr[1].ToString(), dr[2].ToString(), dr[3].ToString()); // 0: UserCode, 1: Password, 2: Roll Name, 3: Email } StatusLabel.Text = "Import status: File had imported."; } catch (Exception ex) { StatusLabel.Text = "Import status: The file could not be imported. The following error occured: " + ex.Message; } } }
protected void UploadButton_Click(object sender, EventArgs e) { if (FileUploadControl.HasFile) { try { string filePath = ConfigurationManager.AppSettings["LocalFilePath"]; string filename = Path.GetFileName(FileUploadControl.FileName); FileUploadControl.SaveAs(filePath + filename); ProcessFile(); StatusLabel.Text = "Upload status: File uploaded !"; StatusLabel.ForeColor = System.Drawing.Color.Green; } catch (Exception ex) { StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message; StatusLabel.ForeColor = System.Drawing.Color.Red; } } else { StatusLabel.Text = "You must select a file"; StatusLabel.ForeColor = System.Drawing.Color.Red; } }
public void SaveFile(string filename) { if (FileUploadControl.HasFile) { FileUploadControl.SaveAs(Server.MapPath("~/Uploaded_Files") + filename); } }
protected void UploadButton_Click(object sender, EventArgs e) { if (FileUploadControl.HasFile) { try { string filename = Path.GetFileName(FileUploadControl.FileName); FileUploadControl.SaveAs(Server.MapPath("~/folder/") + filename); using (SqlConnection conn = new SqlConnection(con)) { conn.Open(); SqlCommand comm = new SqlCommand(); comm.Connection = conn; comm.CommandType = CommandType.StoredProcedure; comm.CommandText = "sp_uploadCv"; comm.Parameters.AddWithValue("@id", Request.QueryString["id"]); comm.Parameters.AddWithValue("@link", MapPath("~/folder/") + filename); int ire = comm.ExecuteNonQuery(); if (ire < 1) { Response.Write("<script>alert('Đăng thất bại')</script>"); } else { Response.Write("<script>alert('Đăng thành công!!')</script>"); } } StatusLabel.Text = "Upload status: File uploaded!"; } catch (Exception ex) { StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message; } } }
protected void UploadButton_Click(object sender, EventArgs e) { divselect.Visible = false; if (FileUploadControl.HasFile) { if ( //FileUploadControl.PostedFile.ContentType.Equals("application/vnd.ms-excel") || //formato 2003 FileUploadControl.PostedFile.ContentType.Equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) // formato superior 2003 { try { string[] name = Path.GetFileName(FileUploadControl.FileName).ToString().Split('.'); string UploadFilePath = Server.MapPath("UploadFile\\"); string path = UploadFilePath + name[0] + "_" + System.DateTime.Now.ToFileTime() + "." + name[1]; if (!Directory.Exists(UploadFilePath)) { Directory.CreateDirectory(UploadFilePath); } FileUploadControl.SaveAs(path); BasePage obj = new BasePage(); //Lê o Excel e converte para DataSet DataTable dt = obj.ReadExcelFile(path); bool ret = false; if (Session["ObjCarga"] != null) { ret = cdBLL.ImportarDados((CargaDados)Session["ObjCarga"], dt); } if (ret) { ListaTodos(); MostraMensagemTelaUpdatePanel(upSimulacao, " Arquivo Carregado com sucesso\\n\\nQuantidade de linhas importados " + dt.Rows.Count + " registros"); } } catch (Exception ex) { MostraMensagemTelaUpdatePanel(upSimulacao, "Atenção\\n\\nO arquivo não pôde ser carregado.\\nMotivo:\\n" + ex.Message); } finally { FileUploadControl.FileContent.Dispose(); FileUploadControl.FileContent.Flush(); FileUploadControl.PostedFile.InputStream.Flush(); FileUploadControl.PostedFile.InputStream.Close(); } } else { MostraMensagemTelaUpdatePanel(upSimulacao, "Atenção\\n\\nCarregue apenas arquivos Excel 2007 (.xlsx) ou superior!"); } } else { MostraMensagemTelaUpdatePanel(upSimulacao, "Atenção\\n\\nSelecione um Arquivo para continuar!"); } }
// The upload picture buttonw as pressed protected void UploadButton_Click(object sender, EventArgs e) { using (SliceOfPieClient.Service.SliceOfPieServiceClient serv = new SliceOfPieClient.Service.SliceOfPieServiceClient()) { //First it check if a file was selected if (FileUploadControl.HasFile) { // gets the file name string ImgName = System.IO.Path.GetFileName(FileUploadControl.FileName); // It saves the picture on the filesystem string ThisImg = Server.MapPath("~/images/" + ImgName); FileUploadControl.SaveAs(ThisImg); // It creates a new bitmap, and then a new object of our own Picture class Bitmap bm = new Bitmap(ThisImg); Picture pic = new Picture(bm); // Finally adds the image to the documents imagelist if (activeDoc != null) { activeDoc.Images.Add(pic); } } // It also saves the document to the server, after the picture is added serv.SaveDocumentOnServer(activeProject, activeDoc, WelcomeForm.active); // Updates the panel in which you can see which pictures are added, so you can see it as soon as you click upload UpdateImagePanel(); ImagesCurrentlyBox.Visible = true; ImageBox.Visible = true; } }
protected void UploadButton_Click(object sender, EventArgs e) { if (FileUploadControl.HasFile) { try { if (FileUploadControl.PostedFile.ContentType == "image/jpeg") { if (FileUploadControl.PostedFile.ContentLength < 1024000) { string filename = Path.GetFileName(FileUploadControl.FileName); Boolean movement = Boolean.Parse(movementRadioButton.SelectedValue); FileUploadControl.SaveAs(Server.MapPath("~/Uploads/") + filename); StatusLabel.Text = "Upload status: File uploaded!"; // Open DataBase connection and send to DB sendToDB("~/Uploads/" + filename, movement); } else { StatusLabel.Text = "Upload status: The file has to be less than 1000 kb!"; } } else { StatusLabel.Text = "Upload status: Only JPEG files are accepted!"; } } catch (Exception ex) { StatusLabel.Text = "Upload status: The file could not be uploaded: " + ex.Message; } } }
protected void btnRegisterUser_Click(object sender, EventArgs e) { if (FileUploadControl.HasFile) { try { if (FileUploadControl.PostedFile.ContentType == "image/jpeg" || FileUploadControl.PostedFile.ContentType == "image/png") { if (FileUploadControl.PostedFile.ContentLength < 102400) { string fileName = Path.GetFileName(FileUploadControl.FileName); FileUploadControl.SaveAs(MapPath("~/UploadFiles/") + fileName); tree.insertar(new User(txtNombreCompleto.Text, txtEmail.Text, txtPassword.Text, txtUserName.Text, txtTelefono.Text, MapPath("~/UploadFiles/") + fileName)); } } else { ErrorMessage.Visible = true; FailureText.Text = "Solo se pueden imagenes jpg :'v"; } } catch { ErrorMessage.Visible = true; FailureText.Text = "Hubo un error de procesamiento, contacte con el administrador!"; } } }
protected void UploadButton_Click(object sender, EventArgs e) { if (FileUploadControl.HasFile) { try { if (FileUploadControl.PostedFile.ContentType == "image/jpeg") { if (FileUploadControl.PostedFile.ContentLength < 10240000) { string filename = System.IO.Path.GetFileName(FileUploadControl.FileName); FileUploadControl.SaveAs(Server.MapPath("/Cloud") + filename); StatusLabel.Text = "Upload status: File uploaded!"; } else { StatusLabel.Text = "Upload status: The file has to be less than 100 kb!"; } } else { StatusLabel.Text = "Upload status: Only JPEG files are accepted!"; } } catch (Exception ex) { StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message; } } }
protected void Button5_Click(object sender, EventArgs e) { string str; if (FileUploadControl.HasFile) { try { string filename = Path.GetFileName(FileUploadControl.FileName); str = Server.MapPath("~/jegadesh/") + filename; FileUploadControl.SaveAs(Server.MapPath("~/jegadesh/") + filename); StreamReader reader1 = new StreamReader(str); string text1 = reader1.ReadToEnd(); TextBox1.Text = text1; reader1.Close(); // Label2.Text = "Upload status: File uploaded!"; FileInfo fi = new FileInfo(str); double imageMB = fi.Length; Session["filesi"] = imageMB; //Label13.Text = "File Name: " + fi.Name; //Label14.Text = "Text Size: " + imageMB + " Bytes"; //Session["filesize"] = Label14.Text; } catch (Exception ex) { Label2.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message; } } }
protected void Upload(ColorItem item) { try { if (FileUploadControl.HasFile) { string directory = Server.MapPath("~/images/palette/"); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } string newFileName = String.Format("{0}{1}{2}", directory, item.ColorID, Path.GetExtension(FileUploadControl.FileName)); if (File.Exists(newFileName)) { File.Delete(newFileName); } FileUploadControl.SaveAs(newFileName); } } catch (Exception ex) { ProcessException(ex); } }
private bool EsImagenCargada() { bool resultado = false; if (FileUploadControl.HasFile) { try { if (FileUploadControl.PostedFile.ContentType == "image/jpeg") { string filename = Path.GetFileName(FileUploadControl.FileName); FileUploadControl.SaveAs(Server.MapPath("~/images/") + filename); hdnRutaImagen.Value = "../images/" + filename; resultado = true; } else { messageBox.ShowMessage("Solo puede cargar imagenes .JPG"); } } catch (Exception ex) { hdnRutaImagen.Value = ""; messageBox.ShowMessage(ex.Message + ex.StackTrace); } } else { messageBox.ShowMessage("Debe agregar un logo a la empresa"); } return(resultado); }
protected void UploadButton_Click(object sender, System.EventArgs e) { if (FileUploadControl.HasFile) { try { if (FileUploadControl.PostedFile.ContentType == "image/jpeg") { if (FileUploadControl.PostedFile.ContentLength < 100002400) { string filename = Data.docid + ".jpg"; FileUploadControl.SaveAs(Server.MapPath("~/") + filename); StatusLabel.Text = "Upload status: File uploaded!"; this.Page_Load(null, null); } else { StatusLabel.Text = "Upload status: The file has to be less than 100 kb!"; } } else { StatusLabel.Text = "Upload status: Only JPG files are accepted!"; } } catch (Exception ex) { StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message; } } }
protected void CreateUser_Click(object sender, EventArgs e) { var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>(); var signInManager = Context.GetOwinContext().Get <ApplicationSignInManager>(); var user = new User() { UserName = Username.Text }; if (FileUploadControl.HasFile) { string fileName = user.UserName + DateTime.Now.ToString("dd_MM_yyyy_hh_mm_ss") + ".jpg"; FileUploadControl.SaveAs(Server.MapPath("~/Uploaded_Files/") + fileName); user.Avatar = fileName; } IdentityResult result = manager.Create(user, Password.Text); if (result.Succeeded) { signInManager.SignIn(user, isPersistent: false, rememberBrowser: false); Response.Redirect("~/"); } else { ErrorMessage.Text = result.Errors.FirstOrDefault(); } }
protected void UploadButton_Click(object sender, EventArgs e) { if (FileUploadControl.HasFile) { if (!Directory.Exists(localDirectory)) { Directory.CreateDirectory(localDirectory); } try { if (FileUploadControl.PostedFile.ContentType == "image/jpeg" || FileUploadControl.PostedFile.ContentType == "image/gif" || FileUploadControl.PostedFile.ContentType == "image/png") { string filename = Path.GetFileName(FileUploadControl.FileName); FileUploadControl.SaveAs(localDirectory + @"\" + filename); System.Drawing.Image image = FromFile(localDirectory + @"\" + filename); int width = image.Width; int height = image.Height; double ratio = ((double)(double)height / (double)width); double newHeight = 500; double newWidth = newHeight / ratio; System.Drawing.Image yourImage = resizeImage(image, new Size((int)newWidth, (int)newHeight)); yourImage.Save(localDirectory + "\\thumbs" + @"\" + filename); yourImage.Dispose(); image.Dispose(); StatusLabel.Text = "Upload status: File uploaded!"; } else { StatusLabel.Text = "Upload status: Only JPG, PNG, and GIF files are accepted!"; } } catch (Exception ex) { StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message; } } }
protected void UploadButton_Click(object sender, EventArgs e) { string[] tableNames = new string[] { "GUID", "Date", "Double", "Int", "String" }; string PrimaryKey = "GUID"; string tableName = "[ExampleTable]"; if (FileUploadControl.HasFile) { try { if (FileUploadControl.PostedFile.ContentLength < 302400 && FileUploadControl.PostedFile.ContentType == "application/vnd.ms-excel") { string filename = FileUploadControl.FileName; FileUploadControl.SaveAs(Server.MapPath("~/") + filename); StatusLabel.Text = "Upload status: File uploaded,Validating..."; ProcessFile processResult = new ProcessFile(Server.MapPath("~/ ") + filename, tableNames, tableName, PrimaryKey); StatusLabel.Text = processResult.Process(); GridView1.DataBind(); } else { StatusLabel.Text = "Upload status: The file must be a csv and less than 300 kb"; } } catch (Exception ex) { StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message; } } }
public string FileUpload() { string str = string.Empty; if (FileUploadControl.HasFile) { try { if (FileUploadControl.PostedFile.ContentType == "image/png") { string filename = Path.GetFileName(FileUploadControl.FileName); FileUploadControl.SaveAs(Server.MapPath("~/images/") + filename); StatusLabel.Text = "Upload status: File uploaded!"; str = Server.MapPath("~/images/") + filename; } else { StatusLabel.Text = "Upload status: Only JPEG files are accepted!"; } } catch (Exception ex) { StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message; } } return(str); }
protected void FileUpload1_AfterUpload(object sender, FileUploadControl.FileUploadEventArgs e) { string destFolder = ""; if (FileUpload1.UploadedFiles.Count > 0) { using (ZipFile zip = ZipFile.Read( HttpContext.Current.Request.MapPath( FileUpload1.FilePath + FileUpload1.UploadedFiles[0]))) { destFolder = HttpContext.Current.Request.MapPath("~/installation/tmp/" + FileUpload1.UploadedFiles[0].Substring(0, FileUpload1.UploadedFiles[0].Length - 4)); if (Directory.Exists(destFolder)) Directory.Delete(destFolder, true); zip.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently; zip.ExtractAll( HttpContext.Current.Request.MapPath("~/installation/tmp/")); } InstallHelper.Install(destFolder); } }
protected void FileUpload1_AfterUpload(object sender, FileUploadControl.FileUploadEventArgs e) { loadGrid(); }