88 lines
3.0 KiB
C#
88 lines
3.0 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public partial class mod_fileUploader : SteamWare.UserControl
|
|
{
|
|
/// <summary>
|
|
/// effettuato upload file!
|
|
/// </summary>
|
|
public event EventHandler eh_uploadDone;
|
|
/// <summary>
|
|
/// caricamento pagina
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
this.Page.Form.Enctype = "multipart/form-data";
|
|
if (!Page.IsPostBack)
|
|
{
|
|
StatusLabel.Text = "";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// caricamento file!
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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);
|
|
}
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// content type permesso
|
|
/// </summary>
|
|
public string contTypeFilt { get; set; }
|
|
/// <summary>
|
|
/// nome file con cui salvare
|
|
/// </summary>
|
|
public string fileName { get; set; }
|
|
}
|
|
} |