简体   繁体   English

FineUploader SubmitDelete获取文件名和扩展名

[英]FineUploader submitDelete Get FileName and Extension

I need to call a Web Service before the file is delete so I decided to use the "submitDelete" callback. 在删除文件之前,我需要调用Web服务,因此我决定使用“ submitDelete”回调。 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? Fine Uploader是否有我可以调用的方法来获取此信息?

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. 您可以通过DELETE请求传递所需的任何参数。 In the submitDelete callback, for example, you can call the setDeleteFileParams API method, passing in the filename. 例如,在submitDelete回调中,您可以调用setDeleteFileParams API方法,并传入文件名。 There is a getName API method that will return the name of a file, given the file's ID. 给定文件的ID,有一个getName API方法将返回文件的名称。

I just noticed that the setDeleteFileParams API method is not documented. 我只是注意到没有记录setDeleteFileParams API方法。 I'll open up a bug report and be sure to properly document that in 3.6. 我将打开一个错误报告,并确保正确记录在3.6中。 This method works just like the setParams API method (same parameters). 此方法的工作方式与setParams API方法(相同的参数)相同。 Please note though, that parameters for DELETE requests will be part of the query string. 不过请注意,DELETE请求的参数将是查询字符串的一部分。

Inside your onSubmitDelete callback handler, the following code will retrieve the filename and add it as a parameter for the associated DELETE request: 在您的onSubmitDelete回调处理程序中,以下代码将检索文件名并将其添加为关联的DELETE请求的参数:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM