FineUploader SubmitDelete获取文件名和扩展名 [英] FineUploader submitDelete Get FileName and Extension

查看:202
本文介绍了FineUploader SubmitDelete获取文件名和扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在删除文件之前调用Web服务,因此我决定使用"submitDelete"回调.我要完成的工作是获取文件名及其扩展名.

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.

Fine Uploader是否有一个我可以调用的方法来获取此信息?

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

下面是我当前的代码.

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

推荐答案

您可以在DELETE请求中传递所需的任何参数.例如,在submitDelete回调中,您可以调用setDeleteFileParams API方法,并传入文件名.给定文件ID,有一个getName API方法将返回文件名.

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.

我只是注意到setDeleteFileParams API方法没有记录.我将打开一个错误报告,并确保在3.6中正确记录该报告.此方法的工作方式与setParams API方法(相同的参数)相同.不过请注意,DELETE请求的参数将是查询字符串的一部分.

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.

在您的onSubmitDelete回调处理程序中,以下代码将检索文件名并将其添加为关联的DELETE请求的参数:

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

这篇关于FineUploader SubmitDelete获取文件名和扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆