I want to upload multiple files and store them in a folder and get the path and store it in the database... Any good example you looked for doing multiple file upload...
Note: Files can be of any type...
I want to upload multiple files and store them in a folder and get the path and store it in the database... Any good example you looked for doing multiple file upload...
Note: Files can be of any type...
Here is a function I wrote which returns a more understandable
$_FILES
array.this simple script worked for me.
HTML
create div with
id='dvFile'
;create a
button
;onclick
of that button calling functionadd_more()
JavaScript
PHP
In this way you can add file/images, as many as required, and handle them through php script.
I run foreach loop with error element, look like
It's not that different from uploading one file -
$_FILES
is an array containing any and all uploaded files.There's a chapter in the PHP manual: Uploading multiple files
If you want to enable multiple file uploads with easy selection on the user's end (selecting multiple files at once instead of filling in upload fields) take a look at SWFUpload. It works differently from a normal file upload form and requires Flash to work, though.SWFUpload was obsoleted along with Flash. Check the other, newer answers for the now-correct approach.I know this is an old post but some further explanation might be useful for someone trying to upload multiple files... Here is what you need to do:
name="inputName[]"
multiple="multiple"
or justmultiple
"$_FILES['inputName']['param'][index]"
array_filter()
before count.Here is a down and dirty example (showing just relevant code)
HTML:
PHP:
Hope this helps out!