最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - rename file option not working in dropzone.js - Stack Overflow

programmeradmin1浏览0评论

I've been trying to rename the filename before the upload in dropzone.js but I'm not able to make it work. This is my configuration:

Dropzone.autoDiscover = false;
Dropzone.options.myAwesomeDropzone = {
    url: url,
    paramName: "image",
    dictDefaultMessage: 'Selecciona tus archivos..',
    dictRemoveFile: "Eliminar",
    dictCancelUpload: "Cancelar carga",
    addRemoveLinks: true,
    uploadMultiple: false,
    renameFile: function (file) {
        console.log(file.name);
        file.name = new Date().getTime() + '_' + file.name;
    },
    new Dropzone("div#my-awesome-dropzone");

When it upload nothing is even showing in the js console and the file name is still the same

Has someone gone through this?

I tried this solution: Dropzone.js - How to change file name before uploading to folder

I've been trying to rename the filename before the upload in dropzone.js but I'm not able to make it work. This is my configuration:

Dropzone.autoDiscover = false;
Dropzone.options.myAwesomeDropzone = {
    url: url,
    paramName: "image",
    dictDefaultMessage: 'Selecciona tus archivos..',
    dictRemoveFile: "Eliminar",
    dictCancelUpload: "Cancelar carga",
    addRemoveLinks: true,
    uploadMultiple: false,
    renameFile: function (file) {
        console.log(file.name);
        file.name = new Date().getTime() + '_' + file.name;
    },
    new Dropzone("div#my-awesome-dropzone");

When it upload nothing is even showing in the js console and the file name is still the same

Has someone gone through this?

I tried this solution: Dropzone.js - How to change file name before uploading to folder

Share Improve this question asked Apr 27, 2018 at 0:08 Marco HerrarteMarco Herrarte 1,6207 gold badges22 silver badges43 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 20

The function in renameFile has to return the new name. It's not well explained int the documentation, tested with dropzone.js (version 5.2).

The code inside the renameFile option should look like:

renameFile: function (file) {
    let newName = new Date().getTime() + '_' + file.name;
    return newName;
}
发布评论

评论列表(0)

  1. 暂无评论