question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow selecting both directories and files for upload

See original GitHub issue

Is your feature request related to a problem? Please describe. My users need to be able to select both directories and files for uploads. This sadly can’t be done with in one go because setting the webkitdirectory attribute disables the selection of single files (at least in Chrome on macOS). The best approach I found is providing the user with two buttons: a “upload files” and “upload directory” one. Then call .showFileUpload() from their click handler after setting the webkitdirectory attribute to respectively false or true on the file input. However, this is slightly complicated because there’s no reference to this input available.

Describe the solution you’d like Make the fileInputRef available in the UploadyContext.

Describe alternatives you’ve considered Have .showFileUpload() apply the webkitdirectory option (and also e.g. the multiple one) before calling input.click(). Or even add a .showDirectoryUpload() method that does the same.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
tacohiddinkcommented, May 4, 2021

@mart-jansink maybe I am missing something, but I am able to drag and drop complete nested directories onto the d&d component. Did have to provide these settings:

htmlDirContentParams={{ recursive: true, withFullPath: true}}

0reactions
yoavnirancommented, May 5, 2021

@mart-jansink im conflicted over exposing a ref to the internal input. Im not sure if in the long run it will be good to have that part of the public API. That is why I allowed handing a custom input from the outside for advanced use-cases that are a small fraction of what users typically require. I’ll keep this in mind and think about whether its something to add in the future.

For now Ill move this issue to the discussions section for others to see.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to allow the user to pick any file or directory in an <input ...
The only way to select both files and directories using 'standard' ways is by providing two separate input elements.
Read more >
Upload files and folders to a library - Microsoft Support
In File Explorer, locate the file you want to upload. Select the file, then on the toolbar, select the Cut option. In File...
Read more >
Upload files and folders to Google Drive - Computer
On your computer, go to drive.google.com. At the top left, click New and then File Upload or Folder Upload. Choose the file or...
Read more >
Upload existing files or folders to Google Drive
Click the New button and select Upload folder…. If you see "Enable folder upload" and you're using Chrome, you'll need to update Chrome...
Read more >
Single Control & Drop Zone for File Upload and Directory ...
The folder upload is allowed by the browser through the attributes on the <input type="file" /> that is used to allow file selection....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found