日期:2014-05-17  浏览次数:20450 次

DWZ 下的uploadify 后台怎么得到文件信息.net下的
ashx里面的代码,HttpPostedFile file = context.Request.Files["fileData"];这句不能得到文件的信息
 public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Charset = "utf-8";

            HttpPostedFile file = context.Request.Files["fileData"];
            string uploadPath = HttpContext.Current.Server.MapPath(@context.Request["folder"]);

            if (file != null)
            {
                if (!Directory.Exists(uploadPath))
                {
                    Directory.CreateDirectory(uploadPath);
                }

                file.SaveAs(Path.Combine(uploadPath, file.FileName));
                //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失
                context.Response.Write("1");
                //context.Response.Write("1|222"); //标志位1标识上传成功,后面的可以返回前台的参数,比如上传后的路径等,中间使用|隔开
            }
            else
            {
                context.Response.Write("0");
            }
        }

前台

<div id="fileQueue" class="fileQueue"></div>
<input id="testFileInput" type="file" name="image" 
uploader="uploadify/scripts/uploadify.swf"
cancelImg="uploadify/cancel.png" 
script="Ajax/UploadHandler.ashx" 
    scriptData="{PHPSESSID:'xxx', ajax:1}"
fileQueue="fileQueue"
folder = "/UpFiles"
onAllComplete="uploadifyAllComplete" 
fileDataName="file"
auto= "false"
fileExt="*.jpg;*.jpeg;*.gif;*.png;"
fileDesc="*.jpg;*.jpeg;*.gif;*.png;"/>

</div>

------解决方案--------------------
确定路径正确吗
------解决方案--------------------
HttpPostedFileBase FileData = Request.Files["fileData"];

注意变量名得用FileData。