using SteamWare; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace CMS_SC.WebUserControls { /// /// /// public partial class mod_fileUploader : SteamWare.UserControl { /// /// effettuato upload file! /// public event EventHandler eh_uploadDone; /// /// caricamento pagina /// /// /// protected void Page_Load(object sender, EventArgs e) { this.Page.Form.Enctype = "multipart/form-data"; if (!Page.IsPostBack) { StatusLabel.Text = ""; } } /// /// caricamento file! /// /// /// protected void btnUpload_Click(object sender, EventArgs e) { if (FileUploadControl.HasFile) { try { if (FileUploadControl.PostedFile.ContentType == contTypeFilt && contTypeFilt != "") { //if (FileUploadControl.PostedFile.ContentLength < 102400000) //{ //string filename = Path.GetFileName(FileUploadControl.FileName); //FileUploadControl.SaveAs(Server.MapPath("~/") + filename); if (fileName == "") { fileName = FileUploadControl.FileName; } string fileDest = string.Format(@"{0}\{1}", memLayer.ML.confReadString("importDataFolder"), fileName); FileUploadControl.SaveAs(fileDest); StatusLabel.Text = string.Format("Upload status: File uploaded! - size: {0} kb", FileUploadControl.PostedFile.ContentLength / 1024); if (eh_uploadDone != null) { eh_uploadDone(this, new EventArgs()); } //} //else // StatusLabel.Text = "Upload status: The file has to be less than 100 Mb!"; } else { StatusLabel.Text = string.Format("{0} - {1}", traduci("ERR-FU-002"), contTypeFilt); } } catch (Exception ex) { StatusLabel.Text = string.Format("{0} {1}", traduci("ERR-FU-001"), ex.Message); } } } /// /// content type permesso /// public string contTypeFilt { get; set; } /// /// nome file con cui salvare /// public string fileName { get; set; } } }