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);
});
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