0
我正在嘗試使用WebAPI爲多個文件上載設置uploadify插件(基於「http://donnyvblog.blogspot.in/2009/05/using-jquery-plugin-uploadify-with.html」文章)。使用WebAPI設置uploadify插件,僅獲取「選擇文件」文本
這裏是我的HTML代碼:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="/scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="/uploadify/jquery.uploadify.min.js"></script>
<script type="text/javascript" src="/client/api scripts/products.js"></script>
<link href="../Uploadify/uploadify.css" type="text/css" />
<script type="text/javascript">
$(document).ready(function() {
// alert("Here");
$("#fileInput").uploadify({
uploader: "/uploadify/uploadify.swf",
script: "/api/files/Upload",
cancelImg: "/uploadify/cancel.png",
auto: true,
folder: "/uploads",
onError: function (a, b, c, d) {
if (d.status == 404)
alert("Could not find upload script. Use a path relative to: " + "<?= getcwd() ?>");
else if (d.type === "HTTP")
alert("error " + d.type + ": " + d.status);
else if (d.type === "File Size")
alert(c.name + " " + d.type + " Limit: " + Math.round(d.sizeLimit/1024) + "KB");
else
alert("error " + d.type + ": " + d.text);
}
});
});
</script>
</head>
<body>
<input type="file" name="fileInput" id="fileInput" />
</body>
</html>
這裏是我的控制器:
public class FilesController : ApiController
{
[HttpPost]
public string Upload(HttpPostedFileBase FileData)
{
/*
*
* Do something with the FileData
*
*/
return "Upload OK!";
}
}
我已經建立了我的路線爲:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
但是,所有我得到的是「選擇文件」文本 - 沒有任何按鈕。我的控制器沒有被調用,也沒有顯示按鈕。我在這裏幹什麼?
謝謝,除了這個uploadify PARAMATERS已在新版本也發生了變化......固定這兩個問題都解決了。 – user2645830