我在下面实现了Uploadify。上传的文件最终将保存到数据库中,但截至目前我只是检查Uploadify是否可以访问该服务。它在IE,Firefox和Safari中取得了成功,但当我或我的域中的其他人在http://machine_name.my_domain.com/SiteName/点击我的网络服务器时,它在Chrome中失败了
我在IIS管理器中启用了Windows身份验证,并为测试用户授予了权限。
但是,所有浏览器在IIS Express开发中都能正常工作。
<input id="inputUploadify" type="file" name="inputUploadify" />
$("#inputUploadify").uploadify({
"buttonImg": "uploadify/customSelect.png",
"rollover": true,
"width": 156,
"height": 40,
"uploader": "uploadify/uploadify.swf",
"expressInstall": "uploadify/expressInstall.swf",
"script": "Services/Uploadify.ashx",
"cancelImg": "uploadify/cancel.png",
"scriptData": { "photoGalleryId": "<%=_photoGalleryId %>" },
"auto": false,
"multi": true,
"fileDesc": "Image files (*.jpg, *.jpeg, *.png)",
"fileExt": "*.jpg;*.jpeg;*.png;",
"sizeLimit": 1048576, //1 MB limit
"removeCompleted": false,
"fileDataName": "fileData",
"onAllComplete": function (event, data) {
if (data.errors == 0) {
alert("Your images have been uploaded.");
}
else {
alert("There was an error uploading images.");
}
},
"onError": function (event, ID, fileObj, errorObj) {
alert("type " + errorObj.type + " " + errorObj.info);
},
"onSelect": function (event, ID, fileObj) {
if (fileObj.size > 1048576) { // 1MB
alert("file '" + fileObj.name + " is too large.");
$(this).uploadifyCancel(ID);
return false;
}
}
});
这是基本的处理程序。
public class Uploadify : IHttpHandler
{
public void ProcessRequest(HttpContext context) {
HttpPostedFile file = context.Request.Files["fileData"];
int photoGalleryId = int.Parse(context.Request["photoGalleryId"]);
context.Response.ContentType = "text/plain";
context.Response.Write("success");
}
public bool IsReusable {
get {
return false;
}
}
}
Fiddler将此显示为401错误
HTTP错误401.2 - 未经授权
由于身份验证无效,您无权查看此页面 头。
这是Firefox的标题
IE9
和Chrome标题
请注意,Chrome标题没有在“Cookie /登录”下列出任何内容(