我想使用這個jQuery文件上傳與我的網站https://github.com/blueimp/jQuery-File-Upload和根據文檔,我將需要創建我自己的文件上傳處理程序,我想知道如果任何人有任何使用jQuery文件上傳在webmatrix網站的經驗?如何在webmatrix(ASP.NET網頁)中使用jQuery文件上傳?
此外,我無法找到我需要創建自己的文件上傳處理程序的信息。如果任何人都可以提供幫助,那就太棒了。
我想使用這個jQuery文件上傳與我的網站https://github.com/blueimp/jQuery-File-Upload和根據文檔,我將需要創建我自己的文件上傳處理程序,我想知道如果任何人有任何使用jQuery文件上傳在webmatrix網站的經驗?如何在webmatrix(ASP.NET網頁)中使用jQuery文件上傳?
此外,我無法找到我需要創建自己的文件上傳處理程序的信息。如果任何人都可以提供幫助,那就太棒了。
Blueimp是一個痛苦的插件......我建議你使用this插件進行表單和文件上傳。其配置更簡單並且非常靈活。 blueimp的問題不僅僅是讓插件準備好使用。在asp.net mvc和asp.net webmatrix上,它在服務器端也很痛苦。
我可以幫助你,我爲我創建的網站創建一個文件(圖像)上傳。
CSHTML部分(sube_archivos.cshtml):
@{
if (IsPost)
{
var fileName = Path.GetFileName(Request.Files["archivo"].FileName);
var fileSavePath = Server.MapPath("~/Temp/" + fileName);
try
{
Request.Files["archivo"].SaveAs(fileSavePath);
<img src="~/Temp/@fileName" /> @*you could comment this line...it was the succesful response...an image preview*@
}
catch (Exception)
{
<text>Error en la subida del archivo</text> @*you could comment this line...error in the uploading*@
}
}
}
JQUERY/JAVASCRIPT部分:
function sube(archivo) {
var primer_archivo = archivo.files[0];
var data = new FormData();
data.append('archivo', primer_archivo);
$.ajax({
url: "@Href("../../operaciones/sube_archivos.cshtml")",
type: "POST",
contentType: false,
data: data,
processData: false,
cache: false,
success: function (response) {
//here I put the response ....the image preview or the error message
$(archivo).parent().next('.imagen_cargada').html(response);
//here I get the file name and I add it to some specific div
$(archivo).parent().next().next('.nombre_imagen').val($(archivo).val().split('\\').pop());
}
});
}
HTML部分:
<form method="post" enctype="multipart/form-data">
<input type="file" name="archivo" onchange="sube(this)" />
</form>
祝你好運,如果Tellme公司有不清楚的地方。