Below is a code I have tinkered with and changed to suit my website needs. It grabs the images and then uploads them individually, making a thumbnail image and then recoridng the data into a database.
The trouble I have is when I upload 5/6 at a time it sometimes doesn't upload anything nor specify whats wrong. I added (error_reporting(~0); ini_set('display_errors', 1);) to check the errors but still nothing shone a light as to what was going on.
Any help would be much appreciated.
PS:- php.ini is set to:-
upload_max_filesize = 60M post_max_size = 60M max_execution_time = 90 max_file_uploads = 30 PHP
$j = 0; $target_path = "../../images/"; $newimagenumber=$currentimages; $imgname = 0; $ImgFileName = 0; for ($i = 0; $i < count($_FILES['file']['name']); $i++) { $target_path = "../../images/"; $imgname = 0; $ImgFileName = 0; $newimagenumber=$newimagenumber+1; $imgname=$_POST['FileName']; $validextensions = array("jpeg", "jpg", "png", "JPG"); $ext = explode('.', basename($_FILES['file']['name'][$i])); $file_extension = end($ext); $ImgFileName="$imgname-$newimagenumber"; $ImgFileNameExt="$imgname-$newimagenumber.jpg"; $target_path = $target_path . $ImgFileName . ".jpg"; $j = $j + 1; if (($_FILES["file"]["size"][$i] < 5000000) && in_array($file_extension, $validextensions)) { if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $target_path)) { $InsertImgFile = mysql_query("INSERT INTO image_data (image_url,image_name,image_customerid,FileName) VALUES ('$ImgFileNameExt','$ImgFileNameExt','$customer_id','$imgname')") or die(mysql_error()); include('CreateNails.php'); // If file moved to uploads folder. echo $j. ').<span id="noerror">Image uploaded successfully!.</span><br/>'; } else { // If File Was Not Moved. echo $j. ').<span id="error">please try again!.</span><br/>'; } } else { // If File Size And File Type Was Incorrect. echo $j. ').<span id="error">***Invalid file Size or Type***</span><br/>'; } } }