Here's some ASP.NET C# code to replace upload.php (upload.ashx)
- Code: Select all
using System;
using System.Web;
using System.IO;
public class Upload : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
HttpPostedFile file = context.Request.Files["Filedata"];
string targetDirectory = Path.Combine(context.Request.PhysicalApplicationPath, context.Request["folder"].Replace("/",""));
string targetFilePath = Path.Combine(targetDirectory, file.FileName);
// Uncomment the following line if you want to make the directory if it doesn't exist
//if (!Directory.Exists(targetDirectory)) Directory.CreateDirectory(targetDirectory);
file.SaveAs(targetFilePath);
context.Response.Write("1");
}
public bool IsReusable
{
get { return false; }
}
}
