1
我一直在寻找这个好几天,但没有成功。我正在尝试为网站创建一个多文件上传系统。我已经尝试了几个jQuery插件,包括SWFUpload和Uploadify。除了实际上传以外,一切正常;上传的文件从不保存到文件夹。我猜测它是我使用.ashx的方式,所以对以下代码错误的任何指导表示赞赏。谢谢,使用.ashx多文件上传
//Jquery is inherited, and I'm pretty sure this is all correct
<link href="/_uploadify/uploadify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="/_uploadify/swfobject.js"></script>
<script type="text/javascript" src="/_uploadify/jquery.uploadify.v2.1.4.min.js"></script>
//Again, this all works as expected. CSS displays, SWF works, the issue I THINK deals
//with 'script' and 'folder'. My Upload.ashx is in the root, as well as uploads folder
<script type="text/javascript">
$(document).ready(function() {
alert("here");
$('#file_upload').uploadify({
'uploader': '/_uploadify/uploadify.swf',
'script': 'Upload.ashx',
'cancelImg': '/_uploadify/cancel.png',
'folder': 'uploads',
'multi': true,
'auto': true
});
});
</script>
<input id="file_upload" name="file_upload" type="file" />
//My handler code, I'm not sure if this works or not but I do know that if
//I try to debug nothing ever fires... I'm sure that's part of the problem
<%@ WebHandler Language="C#" Class="Upload" %>
using System;
using System.Web;
using System.IO;
public class Upload : IHttpHandler {
public void ProcessRequest(HttpContext context)
{
HttpPostedFile file = context.Request.Files["Filedata"];
file.SaveAs("C:\\" + file.FileName);
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
public bool IsReusable
{
get
{
return false;
}
}
}
这就是我拥有的一切。如果我尝试使用SWFUpload jQuery上传文件,它表示它成功,但没有任何文件保存到该文件夹。如果我尝试使用Uploadify,它会因HTTP错误或IO错误而失败,并且再次保存。感谢任何和所有的帮助。
是您的ashx文件在会员区或其他?这可能是一个会话问题。 –