How can I upload folder and files both from same input type?

后端 未结 1 1182
挽巷
挽巷 2021-01-13 12:18

I am using a form where I can upload both, a file or full folder. I am using following code:


  

        
相关标签:
1条回答
  • 2021-01-13 13:19

    As I'm writing this, this is not possible with pure HTML, unless you use some plugin like Flash then maybe it's possible.

    1 file upload:

    <input type="file" name="file">
    

    Multiple files upload (but must be in same folder):

    <input type="file" name="file[]" multiple>
    

    1 folder upload (Note: not all browsers may support this):

    <input type="file" name="file" webkitdirectory directory>
    

    Multiple folders upload maybe not possible currently.

    Here is a trick that might work (but I didn't test it): You can drag and drop file(s) and folder(s) directly in the input field, for example from your desktop to the browser's input. Try selecting files AND folders and drog-n-drop them in your input field, but I don't know if they will be uploaded correctly to the server.

    EDIT:

    Just tested that trick, it didn't work :/

    0 讨论(0)
提交回复
热议问题