我正在使用 uplodifiy 上传我的照片。这是我的代码在下面。但是在 Upload.ashx 处理程序中,我无法获取提交的值(Id 和 foo 值)。它们返回空值。我该如何解决这个问题。谢谢。我有这样的代码
$(document).ready(function () {
var id = "55";
var theString = "asdf";
$("#<%=FileUpload1.ClientID%>").uploadify({
'uploader': 'Upload.ashx',
'swf': 'uploadify/uploadify.swf',
'script': 'Upload.ashx',
'cancelImg': 'images/cancel.png',
'folder': 'upload',
'multi': true,
'buttonText': 'RESIM SEC',
'fileExt': '*.jpg;*.png;*.gif;*.bmp;*.jpeg',
'auto': false,
'scriptData': { 'id': id, 'foo': theString}
,onAllComplete: function (event, data) {
}
});
});
我的ashx文件是这样的;
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Expires = -1;
try
{
//I tryed both way to get values both both return null values.
string pwd1 = context.Request["Id"];
string pwd2 = context.Request.Form["Foo"];
HttpPostedFile postedFile = context.Request.Files["Filedata"];
string id = context.Request["id"];
string savepath = "";
string tempPath = "";
tempPath = context.Request["folder"];
//If you prefer to use web.config for folder path, uncomment below line:
//tempPath = System.Configuration.ConfigurationManager.AppSettings["FolderPath"];
savepath = context.Server.MapPath(tempPath);
string filename = postedFile.FileName;
if (!Directory.Exists(savepath))
Directory.CreateDirectory(savepath);
string ext = System.IO.Path.GetExtension(filename);
string resimGuid = Guid.NewGuid().ToString();
..........
..........