首页 新闻 会员 周边

uploadify 在Asp.net mvc 3中报各种各样的错误

0
悬赏园豆:40 [已解决问题] 解决于 2013-10-21 12:50

最近在学习MVC,可是做文件上传功能的时候网上都说用这个控件uploadify

网址是http://www.uploadify.com/documentation/uploadify/upload/

我下载了他的DEMO 用来做了 可是出现HTTP ERROR的500 302错误。

后来我重建一个DEMO,并且复制了它这个网站右键源码的连接 

运行后可以了,本来很高兴,结果一觉醒来重新打开项目之后又是报这个错误

。然后把移动到其他项目看看,还是这样 各种HTTPERROR错误

前台


<link rel="stylesheet" type="text/css" href="http://www.uploadify.com/wp-content/themes/uploadify/style.css">
<script type="text/javascript" src="http://www.uploadify.com/wp-content/themes/uploadify/js/jquery.min.js"></script>
<script type="text/javascript" src="http://www.uploadify.com/wp-content/themes/uploadify/js/jquery.uploadify.min.js"></script>

<input type="file" name="file_upload" id="file_upload" />
<a href="javascript:$('#file_upload').uploadify('upload','*')">Upload Files</a>
<script type="text/javascript">
    $(function () {
        $("#file_upload").uploadify({
            'auto': false,
            'swf' : '@Url.Content("~/Content/uploadify.swf")',
            'uploader': '/Home/PhotosUpload'
        });
    });

</script>

后台 

 public ActionResult Index()
        {
            return View();
        }
        ///然后选好图片,点击上传
        [HttpPost]
        public ContentResult PhotosUpload(string AlbumID)
        {

            Response.ContentType = "text/plain";
            Response.Charset = "utf-8";
           
            for (int i = 0; i < Request.Files.Count; i++)
            {
                HttpPostedFileBase postedFile = HttpContext.Request.Files[i];

                string filepath = Path.Combine(HttpContext.Server.MapPath("../Upload"), Path.GetFileName(postedFile.FileName));
                postedFile.SaveAs(filepath);
               
            }
            Response.Write("Upload The File Successfully!");
            return Content("11");

        }

求大侠指教!!!!!!!。悲痛中!!

大芝麻的主页 大芝麻 | 初学一级 | 园豆:4
提问于:2013-10-21 12:12
< >
分享
最佳答案
0
收获园豆:20
悟行 | 专家六级 |园豆:12559 | 2013-10-21 12:40

大神!!!膜拜!!!换成这个函数就可以了!好文啊,然后我按照楼下的单步了一下发现路径错误!= =。

我果然还是太菜了。

大芝麻 | 园豆:4 (初学一级) | 2013-10-21 12:48

@大芝麻: 这篇文章很好,希望以后有同样问题的人可以看这篇文章

大芝麻 | 园豆:4 (初学一级) | 2013-10-21 12:49
其他回答(1)
0

500一般是你这边程序出错了,你可以单步调试一下。

或者你可以试试 public ContentResult PhotosUpload(HttpPostedFileBase fileData, string AlbumID)

收获园豆:20
Tinki | 园豆:340 (菜鸟二级) | 2013-10-21 12:41

如您所说,唉 我怎么就没单步了呢!!

支持(0) 反对(0) 大芝麻 | 园豆:4 (初学一级) | 2013-10-21 12:48
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册