sticks
11-15-2002, 09:59 PM
Hi. I had a script made for adding a product to a database which includes linking to an image that is uploaded to a folder. This is all working well. Only thing is the script will not proceed if the user does not choose an image to upload. I want to make this a choice not a requirement. The relevant part of the code is below:-
if(isset($_FILES['files'])) {
if($_FILES['files']['type'] == 'image/gif' ||
$_FILES['files']['type'] == 'image/pjpeg' ||
$_FILES['files']['type'] == 'image/jpeg' ||
$_FILES['files']['type'] == 'image/jpg' &&
is_uploaded_file($_FILES['files']['tmp_name']) == true) {
move_uploaded_file($_FILES['files']['tmp_name'],'images/uploads/'. $_FILES['files']['name']);
$sql .= " ,imgname = '". DBUploadDir . $_FILES['files']['name'] . "'";
} else {
die('invalid image type. make sure your image type is a gif or jpeg. or the file is not a uploaded file.<br>
please use your back button and correct this.');
}
}
I was hoping someone could help with what I would need to do to make this an option. Thanking you, Sheryll.
if(isset($_FILES['files'])) {
if($_FILES['files']['type'] == 'image/gif' ||
$_FILES['files']['type'] == 'image/pjpeg' ||
$_FILES['files']['type'] == 'image/jpeg' ||
$_FILES['files']['type'] == 'image/jpg' &&
is_uploaded_file($_FILES['files']['tmp_name']) == true) {
move_uploaded_file($_FILES['files']['tmp_name'],'images/uploads/'. $_FILES['files']['name']);
$sql .= " ,imgname = '". DBUploadDir . $_FILES['files']['name'] . "'";
} else {
die('invalid image type. make sure your image type is a gif or jpeg. or the file is not a uploaded file.<br>
please use your back button and correct this.');
}
}
I was hoping someone could help with what I would need to do to make this an option. Thanking you, Sheryll.