I'm using the image upload tool uploadify in a webmatrix project. therefore, I have a webhandler which also creates a directory for every upload. Now I need the value of this created folder posted back on my site. Could you pleas help me with this. The webhandler
looks like this:
<%@ WebHandler Language="C#" Class="Upload" %>
using System;
using System.Web;
using System.IO;
public class Upload : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
context.Response.Expires = -1;
try
{
HttpPostedFile postedFile = context.Request.Files["Filedata"];
string savepath = "";
var dirName = string.Format("{0:yyyyMMdd_hhmmss}", DateTime.Now);
savepath = Path.Combine(@"D:\VisualStudio\Websites\AppHome\uploads\", dirName);
string filename = postedFile.FileName;
if (!Directory.Exists(savepath))
Directory.CreateDirectory(Path.Combine(@"D:\VisualStudio\Websites\AppHome\uploads\", dirName));
postedFile.SaveAs(savepath + @"\" + filename);
context.Response.Write(dirName + "/" + filename);
context.Response.StatusCode = 200;
context.Response.Write(dirName);
}
catch (Exception ex)
{
context.Response.Write("Error: " + ex.Message);
}
}
public bool IsReusable {
get {
return false;
}
}
}
being_mp
Member
42 Points
26 Posts
post parameters from webhandler to form
Mar 01, 2012 01:00 PM|LINK
I'm using the image upload tool uploadify in a webmatrix project. therefore, I have a webhandler which also creates a directory for every upload. Now I need the value of this created folder posted back on my site. Could you pleas help me with this. The webhandler looks like this:
<%@ WebHandler Language="C#" Class="Upload" %> using System; using System.Web; using System.IO; public class Upload : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Expires = -1; try { HttpPostedFile postedFile = context.Request.Files["Filedata"]; string savepath = ""; var dirName = string.Format("{0:yyyyMMdd_hhmmss}", DateTime.Now); savepath = Path.Combine(@"D:\VisualStudio\Websites\AppHome\uploads\", dirName); string filename = postedFile.FileName; if (!Directory.Exists(savepath)) Directory.CreateDirectory(Path.Combine(@"D:\VisualStudio\Websites\AppHome\uploads\", dirName)); postedFile.SaveAs(savepath + @"\" + filename); context.Response.Write(dirName + "/" + filename); context.Response.StatusCode = 200; context.Response.Write(dirName); } catch (Exception ex) { context.Response.Write("Error: " + ex.Message); } } public bool IsReusable { get { return false; } } }post uploadify form upload