Hi
i will try and put this as plainly as possible.
I have created a form that can upload up to 6 different images.
You can however upload less than this number.
The root to where the image is sitting is going into the database, which is what i want, but also when no image is selected the root is still going into the database as expected.
I need to put in a if statement that inserts nothing when no image is uploaded, but everything i have tryed seems to fail.
Below is my insert_images.php page.
On a similar note is it possible to add if statements to a insert into (tablename) query???
/ In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.
$uploaddir = "c:/wwwroot/chcc/image_uploads/";
$uploadfile1 = $uploaddir . $FILES['image_1']['name'];
$uploadfile2 = $uploaddir . $FILES['popup_1']['name'];
$uploadfile3 = $uploaddir . $FILES['image_2']['name'];
$uploadfile4 = $uploaddir . $FILES['popup_2']['name'];
if (!move_uploaded_file($FILES['image_1']['tmp_name'], $uploadfile1)) {
print "You have no image selected for image 1<br>";
//print_r($FILES);
}
if (!move_uploaded_file($FILES['popup_1']['tmp_name'], $uploadfile2)) {
print "You have no image selected for image 1 pop up<br>";
//print_r($FILES);
}
if (!move_uploaded_file($FILES['image_2']['tmp_name'], $uploadfile3)) {
print "You have no image selected for image 2<br>";
//print_r($FILES);
}
if (!move_uploaded_file($FILES['popup_2']['tmp_name'], $uploadfile4)) {
print "You have no image selected for image 2 pop up<br>";
//print_r($FILES);
}
//now to take the uploaded doc and put path into database
/$file = $file_array['tmp_name'];
$file_name =$file_array['name'];/
$conn = mysql_connect("$glob_host", "$glob_user", "$glob_pass")
or die(mysql_error());
mysql_select_db("chcc",$conn) or die(mysql_error());
//create and issue the query
$sql = "INSERT INTO image_test
VALUES('$uploadfile1',
'$uploadfile2',
'$uploadfile3',
'$uploadfile4')";
$result = mysql_query($sql,$conn)or die(mysql_error());