My very basic solution would be using Javascript make a button create multiple <input class=" id="app_photo" name="app[photo1]" type="file"> and increment the photo number as you add more photos. This seems more of a hack though.
If we had multiple file inputs and if the user selected photos for all of them, we would have multiple files in this directory. Plug will make sure all the filenames are unique.
So I guess I’ll have to access the system files to get the names?
Update.
I tried to print out the files in the director but I got this: could not list directory "/var/folders/tm/4nhcmhhx5sbcg1st3_kywz400000gn/T//plug-1471/multipart-498792-367218-1": not a directory
Note: This file is temporary, and Plug will remove it from the directory as the request completes. If we need to do anything with this file, we need to do it before then.
Do you process your files while request is still alive?
And I believe that multipart-498792-367218-1 is the name of a file not a directory.
Hi @sysashi, I ran it as soon as I received the files in the backend. Also it returns File.exists?(path) as true, but fails to copy. I tried doing both File.copy and File.cp_r to cover file/directory cases.
** (File.CopyError) could not copy recursively from "/tmp/plug-1471/multipart-502403-126347-3" to "/Users/User/Documents/Programming/temp/". /tmp/plug-1471/multipart-502403-126347-3: illegal operation on a directory
I’ve just tried to do the same thing and everything works fine when you upload a single file, but when you do multiple: true and upload many files, Plug.Upload returns only path for one of the files
Also if i’ve uploaded multiple files at once I get as many multipart-some_numbers-*-* files and some_numbers are same for one upload. So maybe it is a way to determine which files were uploaded?
Thanks @sysashi. I didn’t understand what you were saying at first but you were right. I think I was blinded by what I was expecting to see from the library.