-
Notifications
You must be signed in to change notification settings - Fork 51
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
Multi-file uploads fail when placed under same 'name' attribute in html form #66
Comments
Hi @iandwelker, That's a very accurate assessment. To tell you the truth I don't think I considered HTML 5 Log story short, yes this could be an easy enhancement to make. I see three options:
Do you have another idea? Which one of these would seem more natural to you? Is there an accepted practice? What do web languages/frameworks do? (rails, php, express, .net) Thanks for using Criollo and taking the time to dig and write. Best, |
I'm not an experienced web developer (I've only ever used php out of those you listed), so I really don't know what the accepted practice would be, but I'm fairly certain php's solution is similar to option 3 in your comment above. I like that solution, since it makes the return value easier to deal with (so you don't have to check if every file is an array or just a single file), but I feel it could break apps that currently use Criollo if every file is now treated as an array of files. I feel like option 1, with a dynamic return type based on how many files were uploaded, would be much better for use here. Anyone who was previously using this framework to upload files would still have it work just fine, but it would also support multi-file uploads for those who would like to use it for that. Option 2 would probably work as well, but the framework would then be inserting values into the files that the user didn't ask for, and although it probably wouldn't be too bad to deal with, I think option 1 just does the job more efficiently and cleaner. It also seems to better line up with how the corresponding html tags are formatted. |
I made a pull request that should fix this issue, implementing option 1 that you mentioned before. Could you check it out and let me know what you think? |
It appears, in my limited testing, that when you have an html form with multiple files being uploaded under the same
name
attribute, only one of the files is available to manipulate in the request completion handler. Example code:HTML form (with which multiple files are uploaded):
Swift handler:
When I upload multiple files the input above, only the one file (as shown in the swift bit) appears to be available. I believe this is due to
-(BOOL)appendFileData:(NSData *)data forKey:(NSString *)key
inCRRequest.m
. It seems that it treats thename
attribute's value of the file's input tag as the dictionary key, and so overwrites each new file that comes along with that same name attribute. Is there a simple fix to this (or did I accidentally read over some crucial part of the documentation)?The text was updated successfully, but these errors were encountered: