在asp.net MVC中,uploadify不起作用 [英] In asp.net MVC uploadify is not working
本文介绍了在asp.net MVC中,uploadify不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
代码如下:
查看
---------
the code is given below
view
---------
@{
ViewBag.Title = "Index";
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Upload Files</title>
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery-1.8.2.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/Uploadify/jquery.uploadify.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/Uploadify/jquery.uploadify.min.js")"></script>
<link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/Uploadify/uploadify.css")" />
<script type="text/javascript">
$(function () {
$('#file_upload').uploadify({
'swf': "@Url.Content("~/Content/Uploadify/uploadify.swf")",
'cancelImg': "@Url.Content("~/Content/Uploadify/uploadify-cancel.png")",
'uploader': "@Url.Action("Upload", "Home")",
'onUploadSuccess': function (file, data, response) {
$("#uploaded").append("<img src='" + data + "' alt='Uploaded Image' />");
}
});
});
</script>
</head>
<body>
<div>
Click Select files to upload files.
<input type="file" name="file_upload" id="file_upload" />
</div>
<div id="uploaded">
</div>
</body>
</html>
控制器
-----------
controller
-----------
public ActionResult Upload()
{
var file = Request.Files["Filedata"];
string savePath = Server.MapPath(@"~\Content\" + file.FileName);
file.SaveAs(savePath);
return Content(Url.Content(@"~\Content\" + file.FileName));
}
请帮帮我
提前谢谢
pls help me
thanks in advance
推荐答案
( function (){
(' #file_upload')。uploadify({
' swf': @ Url.Content(〜/ Content / Uploadify / uploadify.swf ),
' cancelImg': @ Url.Content(〜/ Content / Uploadify / uploadify-cancel.png ),
' uploader': @ Url.Action(上传 ,主页 ),
< span class =code-string>' onUploadSuccess': function (文件,数据) ,响应){
('#file_upload').uploadify({ 'swf': "@Url.Content("~/Content/Uploadify/uploadify.swf")", 'cancelImg': "@Url.Content("~/Content/Uploadify/uploadify-cancel.png")", 'uploader': "@Url.Action("Upload", "Home")", 'onUploadSuccess': function (file, data, response) {
( #uploaded)。 append( < img src =' + data + 'alt ='上传的图片'/>);
}
});
});
< / script >
< / head >
< 正文 >
< div >
点击选择文件上传文件。
< 输入 < span class =code-attribute> type = file 名称 = file_upload id = file_upload / >
< / div < span class =code-keyword>>
< div id = 已上传 >
< ; / div >
< / body >
< / html >
("#uploaded").append("<img src='" + data + "' alt='Uploaded Image' />"); } }); }); </script> </head> <body> <div> Click Select files to upload files. <input type="file" name="file_upload" id="file_upload" /> </div> <div id="uploaded"> </div> </body> </html>
控制器
-----------
controller
-----------
public ActionResult Upload()
{
var file = Request.Files["Filedata"];
string savePath = Server.MapPath(@"~\Content\" + file.FileName);
file.SaveAs(savePath);
return Content(Url.Content(@"~\Content\" + file.FileName));
}
请帮助我
提前谢谢
pls help me
thanks in advance
这篇关于在asp.net MVC中,uploadify不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文