i am trying to make a form to the user modify some values of a database
if the user leaves the field "image" (type=file) in blank we assume that the existing image is ok and there's no need to change it.
My problem is that with this code if the field is left in blank it assumes that the file has been uploaded
#Here's the problem it assumes that the file is uploaded
#Is there a way to check it other way?
if (is_uploaded_file($HTTP_POST_FILES['imagem']['tmp_name'])) {
$img = date('YmdHis') . ".jpg";
$directoria = "../imagens/" . $IMGNAME;
copy($HTTP_POST_FILES['imagem']['tmp_name'], $directoria);
} else {
$img = $HTTP_POST_VARS['img'];
}
$id = $HTTP_POST_VARS['id'];
$titulo = $HTTP_POST_VARS['titulo'];
$resumo = $HTTP_POST_VARS['resumo'];
$noticia = $HTTP_POST_VARS['noticia'];
$data = $HTTP_POST_VARS['ano'].$HTTP_POST_VAR['mes'].$HTTP_POST_VARS['dia'].$HTTP_POST_VARS['hora'].$HTTP_POST_VARS['minutos'];
$updateSQL = sprintf("UPDATE noticias SET titulo='$titulo', resumo='$resumo', noticia='$noticia', data='$data', imagem='$img' WHERE id='$id'");
mysql_select_db($database_noticias, $noticias);
$Result1 = mysql_query($updateSQL, $noticias) or die(mysql_error());