How to get folder name and directory for webuploader upload folder

now the file management project built with vue uses Baidu"s webuploader upload plug-in for uploading files

        $(".webuploader-element-invisible").attr("webkitdirectory", "")

this code supports uploading folders

now to support uploading a folder and create a corresponding folder based on the name of the folder and the directory under the folder, how can you get the name of the folder itself and the name of the directory under the folder

the effect is similar to uploading a folder to a Baidu network disk

Mar.10,2021

when debugging the front end, you can clearly see the value of webkitRelativePath, as shown in the screenshot below:

clipboard.png

the specific code is

 // 
    uploader.on('uploadBeforeSend', function(object, data, headers) {
        // webkitdirectorywebkitRelativePathformData
        console.log("uploadBeforeSend:");
        console.log(object);//webkitRelativePath
        data.relativepath = object.file.source.source.webkitRelativePath ? object.file.source.source.webkitRelativePath : '';
        console.log("webkitRelativePath:"+data.relativepath);
    });

it is important to note that when you select the picture folder to upload, set compress:false, (do not compress images before upload)
otherwise webkitRelativePath is empty and cannot be obtained.

Menu