首先,我检查了所有的SO线程,并搜索了我的大脑。我一定错过了一些明显的东西。 我真的很感激一些帮助!这就是我所拥有的。
UploadController.cs
using System.Web;
using System.Web.Mvc;
namespace NIMDocs.Controllers
{
public class UploadController : Controller
{
public ActionResult Index()
{
return View();
}
public string Processed(HttpPostedFileBase FileData)
{
// DO STUFF
return "DUHR I AM SMART";
}
}
}
上传索引
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ITS A TITLE </title>
<script src="../../Content/jqueryPlugins/uploadify/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="../../Content/jqueryPlugins/uploadify/swfobject.js" type="text/javascript"></script>
<script src="../../Content/jqueryPlugins/uploadify/jquery.uploadify.v2.1.0.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#uploadify').fileUpload({
'uploader': '../../Content/jqueryPlugins/uploadify/uploadify.swf',
'script': '/Upload/Processed',
'folder': '/uploads',
'multi': 'true',
'buttonText': 'Browse',
'displayData': 'speed',
'simUploadLimit': 2,
'cancelImg': '/Content/Images/cancel.png'
});
});
</script>
</head>
<body>
<input type="file" name="uploadify" id="uploadify" />
<p><a href="javascript:jQuery('#uploadify').uploadifyClearQueue()">Cancel All Uploads</a></p>
</body>
</html>
我在这里缺少什么?我已经尝试了uploadify的“uploader”选项的每个路径排列。绝对路径,'/'前缀等
这就是我所看到的。
这是目录结构。
答案 0 :(得分:4)
你拼写了Processed Procssed ,因此你不会点击'script':'/ Upload / Processed',
更改
public string Procssed(HttpPostedFileBase FileData)
{
// DO STUFF
return "DUHR I AM SMART";
}
到
public string Processed(HttpPostedFileBase FileData)
{
// DO STUFF
return "O SMART ONE HAS SPOKEN";
}
<强> 修改 强>
删除你的jquery脚本代码块和你的html输入,然后使用这段代码
<body>
<input id="fileInput" name="fileInput" type="file" />
<script type="text/javascript">// <![CDATA[
$(document).ready(function () {
$('#fileInput').uploadify({
'uploader': '../../Content/jqueryPlugins/uploadify/uploadify.swf',
'script': '/Upload/Processed',
'cancelImg': 'cancel.png',
'auto': true,
'folder': '/uploads'
});
});
// ]]>
</script>
</body>
答案 1 :(得分:2)
您的拼写“已处理”在javascript调用(Processed
)和方法定义(Procssed
)之间有所不同。那是偶然的吗?
答案 2 :(得分:0)
我不确定,但在经典的ASP ASP.net网络表单中,必须将表单enctype设置为 多部分/格式数据
<form enctype='multipart/form-data'>
<input type='file'>
<input type='Submit'>
</form>