DropZone acceptedFiles type filter

前端 未结 3 1707
野的像风
野的像风 2021-02-05 08:00

I\'ve got a DropZone form working perfectly with one exception, I can\'t seem to limit the file types as precisely as I need to.

Using acceptedFiles: \"image/*\"<

相关标签:
3条回答
  • 2021-02-05 08:36

    More trial and error eventually turned up the solution:

    Dropzone.options.dzone = {
    acceptedFiles: "image/jpeg,image/png,image/gif"
    }
    

    Apparently my error was primarily in using jpg which made it all fail. The above works like a charm.

    0 讨论(0)
  • 2021-02-05 08:49
    <Dropzone
       onDrop={this.handleFilesUpload}
       >
       {({ getRootProps, getInputProps }) => (
       <div {...getRootProps()}>
       <input
       {...getInputProps()}
       accept=".csv" /*you can use any file type */
       />
       <div className="drag-container">
          <img
             className="drag-img"
             src={Drag}
             alt="drag-img"
             />
          <p className="drag-container-para">Drop files here, or click to select files</p>
       </div>
       </div>
       )}
    </Dropzone>
    
    0 讨论(0)
  • 2021-02-05 08:53

    I think you should validate it from the controller as well.

    $this->validate($request, [
    
            'file' => 'required|mimes:jpg,jpeg,png,bmp']
    
        );
    
    0 讨论(0)
提交回复
热议问题