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

javascript - How to get selected filepath in dropzone.js - Stack Overflow

programmeradmin0浏览0评论

I'm using Dropzone.js for uploading files. Now I want to do some additional validation for some files. But I didn't found a way to get the absolute path of selected file. Please anyone tell me whether there have any way to get the file path.

This is the file array returned by dropzone when we add a file

accepted: true
lastModifiedDate: Wed Dec 17 2014 13:01:03 GMT+0530 (IST)
name: "xxxxxx.pdf"
previewElement: div.dz-preview.dz-file-preview.dz-processing
previewTemplate: div.dz-preview.dz-file-preview.dz-processing
processing: true
size: 407552
status: "uploading"
type: "application/pdf"
upload: ObjectwebkitRelativePath: ""
xhr: XMLHttpRequest
__proto__: File

I'm using Dropzone.js for uploading files. Now I want to do some additional validation for some files. But I didn't found a way to get the absolute path of selected file. Please anyone tell me whether there have any way to get the file path.

This is the file array returned by dropzone when we add a file

accepted: true
lastModifiedDate: Wed Dec 17 2014 13:01:03 GMT+0530 (IST)
name: "xxxxxx.pdf"
previewElement: div.dz-preview.dz-file-preview.dz-processing
previewTemplate: div.dz-preview.dz-file-preview.dz-processing
processing: true
size: 407552
status: "uploading"
type: "application/pdf"
upload: ObjectwebkitRelativePath: ""
xhr: XMLHttpRequest
__proto__: File
Share Improve this question asked Mar 2, 2015 at 11:01 JamesJames 2,9844 gold badges32 silver badges56 bronze badges 6
  • 1 did you find an answer to this? I have the exact same question... – CharlesA Commented Mar 17, 2015 at 7:49
  • @CharlesA No, I didn't. – James Commented Mar 17, 2015 at 9:34
  • thanks. fwiw, I managed to solve my problem - which was how to resend the file a second time using additional parameters - by using processFile() mand. Not sure it'll help in your case though – CharlesA Commented Mar 17, 2015 at 13:08
  • @CharlesA it is better if you write your solution as an answer. That may help someone in the future. – James Commented Mar 17, 2015 at 18:35
  • thanks. I didn't do that because it doesn't solve your problem! – CharlesA Commented Mar 17, 2015 at 18:37
 |  Show 1 more ment

1 Answer 1

Reset to default 2

The full path es through in the POST data:

Dropzone.options.yourDropzoneID = {
  init: function() {
    this.on("sending", function(file, xhr, data) {
        if(file.fullPath){
            data.append("fullPath", file.fullPath);
        }
    });
  }
};
发布评论

评论列表(0)

  1. 暂无评论