Upload unlimited files
Moderator: General Moderators
-
mickyjune26
- Forum Commoner
- Posts: 30
- Joined: Mon May 17, 2010 9:52 am
Upload unlimited files
Using PHP, what is the best method to allow a user to upload files one at a time prior to completing a form?
Here is how I visualize:
1. User clicks Browse and selects file
2. User clicks upload and file uploads
3. Page shows newly uploaded file
4. User can click Browse to upload another file or Finish to submit the completed form
So far, i only know how to create more than one file input field ahead of time, limiting the user to upload 5 or less files at the same time, for example.
Thanks in advance.
Here is how I visualize:
1. User clicks Browse and selects file
2. User clicks upload and file uploads
3. Page shows newly uploaded file
4. User can click Browse to upload another file or Finish to submit the completed form
So far, i only know how to create more than one file input field ahead of time, limiting the user to upload 5 or less files at the same time, for example.
Thanks in advance.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Upload unlimited files
If you use Javascript you can add a new file input after they select a file in the first one, etc...
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
mickyjune26
- Forum Commoner
- Posts: 30
- Joined: Mon May 17, 2010 9:52 am
Re: Upload unlimited files
Yeah, I downloaded some scripts, but I don't know js yet. I'm just starting to understand the basics of PHP. If I have to learn js to do this, I will. But I'd like to stay in the realm of php.
Thanks for the quick response!
Thanks for the quick response!
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Upload unlimited files
Do it the way you have outlined. The process would be to make the form submit to itself and on submit it would store the uploaded file name in the session and display the upload form again with the already uploaded files. When they click finish, submit to another page.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
mickyjune26
- Forum Commoner
- Posts: 30
- Joined: Mon May 17, 2010 9:52 am
Re: Upload unlimited files
Per someone's suggestion, we are going a slightly different direction, incorporating some javascript to dynamically add more upload prompts.
http://www.htmlhelpcentral.com/messageb ... to=newpost
http://www.htmlhelpcentral.com/messageb ... to=newpost
-
mickyjune26
- Forum Commoner
- Posts: 30
- Joined: Mon May 17, 2010 9:52 am
Re: Upload unlimited files
The current method of duplicating the browse button let's me select multiple files, but is only uploading one file. Anyone know how I can modify the php processing code so it can upload multiple files?
Form URL: http://www.einstructiontx.com/tester_form.php
PHP processor: http://www.einstructiontx.com/tester_upload.php
The submit button is disabled for now, until i add code to sanitize the uploads.
Form URL: http://www.einstructiontx.com/tester_form.php
PHP processor: http://www.einstructiontx.com/tester_upload.php
The submit button is disabled for now, until i add code to sanitize the uploads.
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
-
mickyjune26
- Forum Commoner
- Posts: 30
- Joined: Mon May 17, 2010 9:52 am
Re: Upload unlimited files
Thanks Jonah. Once I finish my 10 remaining hours of php tutorials on lynda.com in addition to some tutorials that another devnetwork user recommended, I'll research the link you provided. It may be a while because it seems a little too advanced right now. I just built my first working form that updates a MySQL database 
pretty cool stuff.
pretty cool stuff.
-
mickyjune26
- Forum Commoner
- Posts: 30
- Joined: Mon May 17, 2010 9:52 am
Re: Upload unlimited files
Jonah, I think I'm getting closer to understanding what you are meaning.
I found an explaination of how to upload multiple files.
http://www.phpeasystep.com/phptu/2.html
Once I play with and understand this code, I'll try incorporating the link you provided.
I found an explaination of how to upload multiple files.
http://www.phpeasystep.com/phptu/2.html
Once I play with and understand this code, I'll try incorporating the link you provided.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Upload unlimited files
That tutorial is really outdated, but covers the same principles as the previously posted tutorial.mickyjune26 wrote:Jonah, I think I'm getting closer to understanding what you are meaning.
I found an explaination of how to upload multiple files.
http://www.phpeasystep.com/phptu/2.html
Once I play with and understand this code, I'll try incorporating the link you provided.
-
mickyjune26
- Forum Commoner
- Posts: 30
- Joined: Mon May 17, 2010 9:52 am
Re: Upload unlimited files
awesome! I got the dynamic form to successfully upload multiple files to my processor. Now I just need to put some while and count loops in the processor so it can dynamically adjust. It's currently static and limited to 3.
http://www.einstructiontx.com/tester_form.php
http://www.einstructiontx.com/tester_processor.php
http://www.einstructiontx.com/tester_form.php
http://www.einstructiontx.com/tester_processor.php
-
mickyjune26
- Forum Commoner
- Posts: 30
- Joined: Mon May 17, 2010 9:52 am
Re: Upload unlimited files
yeah, I noticed that the tutorial I found was outdated. It was nice how it went into more detail for a newbie like me.
My form and processor are fully functional now! I couldn't have done it without your guidance. I feel like celebrating, now that I've passed my 2nd full day of php coding.
Now I just need to find a way to duplicate the entire row in the form when Add More is clicked. I save that for a forum focusing on Javascript!
Thanks again everyone. I hope to be able to give back to this forum as much as has been given to me.
My form and processor are fully functional now! I couldn't have done it without your guidance. I feel like celebrating, now that I've passed my 2nd full day of php coding.
Now I just need to find a way to duplicate the entire row in the form when Add More is clicked. I save that for a forum focusing on Javascript!
Thanks again everyone. I hope to be able to give back to this forum as much as has been given to me.
Re: Upload unlimited files
mickyjune26:
Would you be willing to post your code? I need to do the same thing and I'd love to see how it's done. Thanks!
Would you be willing to post your code? I need to do the same thing and I'd love to see how it's done. Thanks!
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Upload unlimited files
Great! Looks like you're leaning fast.

-
mickyjune26
- Forum Commoner
- Posts: 30
- Joined: Mon May 17, 2010 9:52 am
Re: Upload unlimited files
Here you go:kgrote wrote:mickyjune26:
Would you be willing to post your code? I need to do the same thing and I'd love to see how it's done. Thanks!
http://www.einstructiontx.com/tester_form.php
http://www.einstructiontx.com/tester_processor.php
Next, I'll configure the files to go to a specific folder based on the drop-down attributes, such as Grade 3 > Science. Also need to add some security metrics.