Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add relative path to upload if webkitdirectory attribute used #1781

Merged
merged 3 commits into from
Aug 5, 2022

Conversation

easink
Copy link
Contributor

@easink easink commented Nov 28, 2021

Now you can do this:
<%= live_file_input @uploads.files, webkitdirectory: true %>
and get %UploadEntry{} with a relative path.

One of the drawbacks of this implementation is that you cannot drag and drop folders, you than need some more javascript to make it work. (https://stackoverflow.com/questions/3590058/does-html5-allow-drag-drop-upload-of-folders-or-a-folder-tree)
But I think this is an important feature as is.

Another drawback is that this not supported on most mobile phones, but should not be a problem anyway.
(https://caniuse.com/?search=webkitdirectory)

There is a reported issue on this: #1482

@mcrumm
Copy link
Member

mcrumm commented Nov 28, 2021

Hi @easink! Thanks for the PR. Generally we avoid adding support for non-standard features. Using the client file name as the default path name is also a concern because it is unsanitized input.

I will leave this open for now though so other can weigh in :)

@josevalim
Copy link
Member

Given the functionality is mostly copying the relative path, I would be ok with supporting it and we can fallback to reading other attributes if supported in the future.

@rsmidt
Copy link

rsmidt commented Jan 14, 2022

I would love to have this in LiveView. Is there something we can do to allow the PR to be merged?

@chrismccord
Copy link
Member

Thank you @easink ! Can you update the PR to make the field relative_path and make it null rather than falling back to name when it's not present? Thanks!

@easink
Copy link
Contributor Author

easink commented Mar 29, 2022

I rebased it to phoenix_live_view/master and github went bananas.

@easink
Copy link
Contributor Author

easink commented May 22, 2022

Does anybody have any trouble with this? Works for me.

@chrismccord chrismccord merged commit 7c2dcda into phoenixframework:master Aug 5, 2022
@chrismccord
Copy link
Member

❤️❤️❤️🐥🔥

camelpunch added a commit to camelpunch/phoenix_live_view that referenced this pull request May 16, 2023
camelpunch added a commit to camelpunch/phoenix_live_view that referenced this pull request May 16, 2023
camelpunch added a commit to camelpunch/phoenix_live_view that referenced this pull request May 16, 2023
la-joshua pushed a commit to atomio-group/phoenix_live_view that referenced this pull request Jun 26, 2024
…xframework#1781)

* Add relative path to upload if webkitdirectory attribute used
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants