.ashx 如何操作页面的用户控件
在一个1.aspx页面里面有个fileuplaod控件,我现在要通过一般处理程序也就是.ashx文件来接受fileuplaod的路径,怎么做,高手求救
...全文
请发表友善的回复…
发表回复
lishuai1030 2010-06-19
- 打赏
- 举报
可以用ajax
保存路径 到变量
然后ajax打开ashx?path=变量
在ashx中接收context.Request.QueryString["path"]就行了
保存路径 到变量
然后ajax打开ashx?path=变量
在ashx中接收context.Request.QueryString["path"]就行了
baiye1134 2010-05-29
- 打赏
- 举报
我是来拿分分分分分的
xshf12345 2010-05-29
- 打赏
- 举报
传过去file,然后在后台处理文件中
context.Response.ContentType = "text/plain";
context.Response.Expires = -1;
try {
HttpPostedFile postedFile = context.Request.Files["Filedata"];
string savepath = "";
string tempPath = "";
tempPath = System.Configuration.ConfigurationManager.AppSettings["FolderPath"];
savepath = context.Server.MapPath(tempPath);
string filename = postedFile.FileName;
string sExtension = filename.Substring(filename.LastIndexOf('.'));
if (!Directory.Exists(savepath))
Directory.CreateDirectory(savepath);
string sNewFileName = DateTime.Now.ToString("yyyyMMddhhmmsfff");
postedFile.SaveAs(savepath + @"\" + sNewFileName + sExtension);
context.Response.Write(tempPath + sNewFileName + sExtension);
context.Response.StatusCode = 200;
}
catch (Exception ex) {
context.Response.Write("Error: " + ex.Message);
}