1
我在ASP.NET MVC應用程序中使用Uploadify。文件上傳後,我們看到: 刪除服務器上傳的文件
如果用戶點擊取消/交叉按鈕,是否可以刪除上載的文件(從服務器)?任何建議/指針都會非常有幫助。
我在ASP.NET MVC應用程序中使用Uploadify。文件上傳後,我們看到: 刪除服務器上傳的文件
如果用戶點擊取消/交叉按鈕,是否可以刪除上載的文件(從服務器)?任何建議/指針都會非常有幫助。
一種可能性是有,一旦上傳完成,可以讓你以後識別服務器上的文件服務器端上傳的動作返回一個唯一的ID:
[HttpPost]
public ActionResult Upload()
{
var fileId = Guid.NewGuid().ToString();
// TODO: do the uploading ...
return Json(new { id = fileId });
}
,並在客戶端上保持地圖之間服務器返回的唯一文件ID和客戶端上的ID。然後,你可以訂閱onComplete和onCancel事件:
$(function() {
var map = {};
$('#file_upload').uploadify({
'uploader': '@Url.Content("~/scripts/uploadify/uploadify.swf")',
'script': '@Url.Action("upload")',
'cancelImg': '@Url.Content("~/scripts/uploadify/cancel.png")',
'auto': true,
'removeCompleted': false,
'multi': true,
'onComplete': function (event, ID, fileObj, response, data) {
// once the upload succeeds we retrieve the id returned
// by the server and we put it in the map
map[ID] = $.parseJSON(response).id;
},
'onCancel': function (event, ID, fileObj, data) {
var fileId = map[ID];
if (fileId) {
// TODO: here you could send a request to the server to
// inform him that the user wants to delete the file with
// the given unique id
}
}
});
});
謝謝。我會試一試。 – GoldenUser 2012-03-05 17:56:41
可以將文件流式傳輸到一個臨時文件夾,並且只要他們不打取消假設他們想上傳的文件..並做背後在初始文件流成功後場景異步文件上傳.. – MethodMan 2012-03-05 16:01:23