asp.net mvc2中Uploadify中的IO / HTTP错误
我正在使用 uploadify 工具上传我的文件而不发回,并且在发布网站后遇到“IO 错误”或“HTTP 错误”问题。
这是我的代码示例:
$('#UploadFile').uploadify({
'uploader': '/Content/uploadify.swf',
'script': '/Home/uploadify',
'cancelImg': '/Content/cancel.png',
'folder': '/Content/UploadedFiles',
'auto': true
});
这是我的操作代码
[HttpPost]
public string uploadify()
{
string fileDirectory = Server.MapPath(@"\Content\UploadedFiles\");
string signuterName = _fileStore.SaveUploadedFile(Request.Files[0], fileDirectory);
Session["SignuterfilePath"] = @"/Content/UploadedFiles/" + signuterName;
return signuterName;
}
http://www.uploadify.com/documentation/
谢谢。
I am using uploadify tool to upload my files with out posting back and I am facing this problem "IO Error" or "HTTP Error" after publishing the site.
This is my code sample :
$('#UploadFile').uploadify({
'uploader': '/Content/uploadify.swf',
'script': '/Home/uploadify',
'cancelImg': '/Content/cancel.png',
'folder': '/Content/UploadedFiles',
'auto': true
});
this is my action code
[HttpPost]
public string uploadify()
{
string fileDirectory = Server.MapPath(@"\Content\UploadedFiles\");
string signuterName = _fileStore.SaveUploadedFile(Request.Files[0], fileDirectory);
Session["SignuterfilePath"] = @"/Content/UploadedFiles/" + signuterName;
return signuterName;
}
http://www.uploadify.com/documentation/
thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎有硬编码的网址,在虚拟目录下部署站点时可能会损坏。我建议您在处理 url 时始终使用 URL 帮助程序:
更新:
您的控制器操作通常返回 ActionResults 而不是字符串:
您还会注意到我已从控制器操作中删除了 Session 调用。原因是 Uploadify 插件使用 Flash,而 Flash 无法访问 cookie,因此执行请求时不会有任何与其关联的 Session。
You seem to have hardcoded urls which might break when deploying your site under a virtual directory. I would recommend you always using URL helpers when dealing with urls:
UPDATE:
Also your controller actions normally return ActionResults not strings:
You will also notice that I have removed the Session call from your controller action. The reason for this is the the Uploadify plugin uses Flash and Flash doesn't have access to cookies, so when the request is performed there won't be any Session associated with it.