Multiple File Uploader

Setting up a file to upload to your site is fairly simple, getting it to work with multiple threw me at first. this is how yer do it.

Fisrt of start your form, make sure to set the encoding type or the upload will fail straight of the bat.

You can set the max uplaod size via html but, this can be overridden, its still good to keep it in, as it will reject a larger file straight away, saves users uploading it and then being told its too large later on. (eg 5mb)

Now whatever the name is set to is important for the next bit, here i’ve used userfile[]

Add any other bits to your form and you should have something like this

now we have our form we need to set up a handler for our files. Now with multiple data files we handle the userfile like an array.

each time we need to reference the file like this

in the full example below I call a database which logs the file and selects the highest id. Adding one and using that value after to keep a steady file id going.

getting to each file, first thing is check if it uploaded. if yes then get the temporary and actual filenames.

then some error checking, firstly checking file-size and then file-type. if both seem okay we move the file into our upload directory.
after we can then move elsewhere if we wish.

we add the info the the mysql database. up the number ready for the next file, and some error messages at the end.

simples.




Leave a Reply

Your email address will not be published. Required fields are marked *

*

question razz sad evil exclaim smile redface biggrin surprised eek confused cool lol mad twisted rolleyes wink idea arrow neutral cry mrgreen

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">