Torna al Thread

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.IO; using System.Web.Script.Serialization; public class FileUpload : IHttpHandler { public void ProcessRequest(HttpContext context) { HttpContext.Current.Server.ScriptTimeout = 7200; context.Response.ContentType = "text/plain"; context.Response.Expires = -1; string type = context.Request["type"]; string id = context.Request["id"]; string result = string.Empty; if (context.Request.Files.Count == 0) { context.Response.ContentType = "text/plain"; context.Response.Write("{\"msg_error\":\"" + Messaggi.ERR_NO_FILE + "\"}"); } else { HttpPostedFile uploadedfile = context.Request.Files["Filedata"]; if (uploadedfile != null && uploadedfile.ContentLength > 0) { string FileName = uploadedfile.FileName; string FileType = uploadedfile.ContentType; int FileSize = uploadedfile.ContentLength; string id_item = "0"; string name = string.Empty; string filename = string.Empty; string link = string.Empty; string error = string.Empty; string param1 = string.Empty; List<string> msg_error = new List<string>(); List<string> param = new List<string>(); LogRequest(FileName + ", " + FileType + ", " + FileSize); switch (type) { case "video_news": ... break; default: break; } } else { result = "{\"msg_error\":\"" + Messaggi.ERR_DESC_ZERO_LENGTH_FILE + "\"}"; } context.Response.ContentType = "text/plain"; context.Response.Write(result); } } public bool IsReusable { get { return false; } } private void LogRequest(string Log) { //StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath("/Log") + "\\Log.txt", true); //sw.WriteLine(DateTime.Now.ToString() + " - " + Log); //sw.Flush(); //sw.Close(); } }
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5