pn523's avatar
Level 2

Retrieve individual file upload from multiple files

I uploaded 4 files and now i want to retrieve every file individually , when tried using foreach it only gives me last file instead of all the files , how do i get all the files individually?

0 likes
2 replies
lostdreamer_nl's avatar
Level 53

are you uploading all files with the same name (input form name I mean) ? The name of the upload fields should end with " [] " to make it an array, otherwise file 2 overwrites file 1, file 3 overwrites file 2 etc. during form submission.

If this is not the case, could you post code of:

  1. The view of the form that is uploading
  2. the part of the controller that is handling the file upload (the foreach loop + how you save the file)

This way we can see what is going wrong instead of just doing educated guess work ;)

pn523's avatar
Level 2

Thanks , name of the uploaded files should end with [] worked for me.

Please or to participate in this conversation.