FineUploader submitDelete Get FileName and Extension

心已入冬 提交于 2019-12-01 13:19:49

问题


I need to call a Web Service before the file is delete so I decided to use the "submitDelete" callback. What I'm trying to accomplish is to get the Name of the File and its extension.

Does Fine Uploader have a method that I could call just get this information?

Below is my current code.

$('#uploader').fineUploader({
    request: {
        endpoint: 'upload.asp'
    },
    deleteFile: {
        enabled: true,
        endpoint: 'Upload.asp'
    },
    multiple: false
}).on('submitDelete', function (id) {
    alert(id);
});

回答1:


You can pass whatever parameters you want with the DELETE request. In the submitDelete callback, for example, you can call the setDeleteFileParams API method, passing in the filename. There is a getName API method that will return the name of a file, given the file's ID.

I just noticed that the setDeleteFileParams API method is not documented. I'll open up a bug report and be sure to properly document that in 3.6. This method works just like the setParams API method (same parameters). Please note though, that parameters for DELETE requests will be part of the query string.

Inside your onSubmitDelete callback handler, the following code will retrieve the filename and add it as a parameter for the associated DELETE request:

.on('submitDelete', function(event, id) {
   var filename = $(this).fineUploader('getName', id);
   $(this).fineUploader('setDeleteFileParams', {filename: filename}, id);
});


来源:https://stackoverflow.com/questions/16305517/fineuploader-submitdelete-get-filename-and-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!