Ok.. I have an optional field in a form to upload a file. If the file isn't the right type it get's an error messege. The problem I'm having now is that if you leave the file name blank... the error messege still pops up.
I did a isset but it seems to just bypass this...
It does do the right thing.. it puts the info in the database. I just need to by pass the error messege if the field is left blank...
// Start File Upload
if (isset($_FILES['Menu_pict']['name'])) {
if ($_FILES['Menu_pict']['type'] == "image/jpeg")
{
copy ($_FILES['Menu_pict']['tmp_name'], "../images/food/".$_FILES['Menu_pict']['name'])
or die ("Could not copy");
echo "<br><br>";
echo "Name: ".$_FILES['Menu_pict']['name']."<br>";
echo "Size: ".$_FILES['Menu_pict']['size']."<br>";
echo "Type: ".$_FILES['Menu_pict']['type']."<br>";
echo "Copy Done....";
}
else
{
echo "<br><br>";
echo "Could Not Copy, Wrong Filetype (".$_FILES['Menu_pict']['name'].")<br>";
}
}
// End File Upload
$Menu_pict = $_FILES['Menu_pict']['name'];
$SQL="UPDATE Main_Menu SET Menu_item='$Menu_item', Menu_desc='$Menu_desc', Menu_price='$Menu_price', Menu_pict='$Menu_pict', Menu_cat='$Menu_cat' WHERE Menu_id=$Menu_id";
$result=mysql_query($SQL,$dB);