I needed a file uploader for a client a little while ago, then the client didn't want it, so I'll share with all of you. I know I hated coding it, it was confusing (for me anyway), but I made it fairly simple to use: Upload files:
"; for($x=0;$x<$num_of_uploads;$x++){ $form .= "*
"; } $form .= "
*Maximum file length (minus extension) is 15 characters. Anything over that will be cut to only 15 characters. Valid file type(s): "; for($x=0;$x $value){ if($_FILES["file"]["name"][$key]!=""){ if($value==UPLOAD_ERR_OK){ $origfilename = $_FILES["file"]["name"][$key]; $filename = explode(".", $_FILES["file"]["name"][$key]); $filenameext = $filename[count($filename)-1]; unset($filename[count($filename)-1]); $filename = implode(".", $filename); $filename = substr($filename, 0, 15).".".$filenameext; $file_ext_allow = FALSE; for($x=0;$x".$filename."
"); }else{ echo($origfilename." was not successfully uploaded
"); } }else{ echo($origfilename." was too big, not uploaded
"); } }else{ echo($origfilename." had an invalid file extension, not uploaded
"); } }else{ echo($origfilename." was not successfully uploaded
"); } } } } } ?> uploader([int num_uploads [, arr file_types [, int file_size [, str upload_dir ]]]]); num_uploads = Number of uploads to handle at once. file_types = An array of all the file types you wish to use. The default is txt only. file_size = The maximum file size of EACH file. A non-number will results in using the default 1mb filesize. upload_dir = The directory to upload to, make sure this ends with a / This functions echo()'s the whole uploader, and submits to itself, you need not do a thing but put uploader(); to have a simple 1 file upload with all defaults.