我已经看了好几天了,但没有成功。我正在尝试为网站创建一个多文件上传系统。我尝试了几个 jQuery 插件,包括 SWFUpload 和 Uploadify。除实际上传外,一切正常;上传的文件永远不会保存到文件夹中。我猜它是我使用 .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 错误而失败,并且再次没有任何保存。感谢您的任何帮助。