joshgarrod Posted February 26, 2009 Share Posted February 26, 2009 Hi, I have a form that submits info into my table and is supposed to upload 4 images too. It uploads the first 1 but the others dont work.... any ideas, thanks in advance PHP: <?php $idir = "uploads/"; // Path To Images Directory if (isset ($_FILES['fupload'])){ //upload the image to tmp directory $url = $_FILES['fupload']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload']['type'] == "image/jpg" || $_FILES['fupload']['type'] == "image/jpeg" || $_FILES['fupload']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload']['tmp_name'], "$idir" . $_FILES['fupload']['name']); // Move Image From Temporary Location To Permanent Location } } if (isset ($_FILES['fupload2'])){ //upload the image to tmp directory $url = $_FILES['fupload2']['name2']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload2']['type'] == "image/jpg" || $_FILES['fupload2']['type'] == "image/jpeg" || $_FILES['fupload2']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload2']['name2'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload2']['tmp_name'], "$idir" . $_FILES['fupload2']['name2']); // Move Image From Temporary Location To Permanent Location } } if (isset ($_FILES['fupload3'])){ //upload the image to tmp directory $url = $_FILES['fupload3']['name3']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload3']['type'] == "image/jpg" || $_FILES['fupload3']['type'] == "image/jpeg" || $_FILES['fupload3']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload3']['name3'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload3']['tmp_name'], "$idir" . $_FILES['fupload3']['name3']); // Move Image From Temporary Location To Permanent Location } } if (isset ($_FILES['fupload4'])){ //upload the image to tmp directory $url = $_FILES['fupload4']['name4']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload4']['type'] == "image/jpg" || $_FILES['fupload4']['type'] == "image/jpeg" || $_FILES['fupload4']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload4']['name4'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload4']['tmp_name'], "$idir" . $_FILES['fupload4']['name4']); // Move Image From Temporary Location To Permanent Location } } error_reporting (E_ALL ^ E_NOTICE); $usr = "61854"; $pwd = "65165"; $db = "5165"; $host = "21.50"; # connect to database $cid = mysql_connect($host,$usr,$pwd); if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); } if ($_POST['submit']) { $make = mysql_real_escape_string($_POST['make']); $model = mysql_real_escape_string($_POST['model']); $year = mysql_real_escape_string($_POST['year']); $berth = mysql_real_escape_string($_POST['berth']); $weightun = mysql_real_escape_string($_POST['weightun']); $weightla = mysql_real_escape_string($_POST['weightla']); $lengthin = mysql_real_escape_string($_POST['lengthin']); $lengthex = mysql_real_escape_string($_POST['lengthex']); $awning = mysql_real_escape_string($_POST['awning']); $spec = mysql_real_escape_string($_POST['spec']); $price = mysql_real_escape_string($_POST['price']); $contactname = mysql_real_escape_string($_POST['contactname']); $contactnum = mysql_real_escape_string($_POST['contactnum']); $contactemail = mysql_real_escape_string($_POST['contactemail']); $county = mysql_real_escape_string($_POST['county']); $image1 = mysql_real_escape_string("$idir" . $_FILES['fupload']['name']); $image2 = mysql_real_escape_string("$idir" . $_FILES['fupload2']['name2']); $image3 = mysql_real_escape_string("$idir" . $_FILES['fupload3']['name3']); $image4 = mysql_real_escape_string("$idir" . $_FILES['fupload4']['name4']); $password = mysql_real_escape_string($_POST['password']); $model_chk = (!isset($_POST['model']) || trim($_POST['model']) == "") ? die ('ERROR: Enter a model') : mysql_escape_string(trim($_POST['model'])); $SQL = " INSERT INTO table"; $SQL .= " (make, model, year, berth, weightun, weightla, lengthin, lengthex, awning, spec, price, contactname, contactnum, contactemail, county, image1, image2, image3, image4, password) VALUES "; $SQL .= " ('$make', '$model', '$year', '$berth', '$weightun', '$weightla', '$lengthin', '$lengthex', '$awning', '$spec', '$price', '$contactname', '$contactnum', '$contactemail', '$county', '$image1', '$image2', '$image3', '$image4', '$password') "; ?> HTML: <input type = "hidden" name="MAX_FILE_SIZE" value = "102400"> <div class="input_row"><div class="input_titles">Select image:</div><div class="input_box"><input type = "file" name = "fupload"></div></div> <div class="input_row"><div class="input_titles">Select image:</div><div class="input_box"><input type = "file" name = "fupload2"></div></div> <div class="input_row"><div class="input_titles">Select image:</div><div class="input_box"><input type = "file" name = "fupload3"></div></div> <div class="input_row"><div class="input_titles">Select image:</div><div class="input_box"><input type = "file" name = "fupload3"></div></div> Link to comment https://forums.phpfreaks.com/topic/146990-solved-image-upload-issues/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.