0
我使用uplodifiy上傳圖片。這裏是我的代碼在below.but 裏面的Upload.ashx處理程序,我coulnt獲取提交的值(Id和foo值)。他們返回空值。 我該如何解決這個問題。謝謝。 我有這樣的代碼獲取ashx文件中的客戶端值
$(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();
..........
..........
完美,非常感謝你 – sakir