director87 Posted September 10, 2007 Share Posted September 10, 2007 I have a simple form that allows a user to update their information, on the same form it allows the user to update their photo (although it's not obligatory). My uploading function returns an error when the user hasn't opted to change their photo, however, I don't know how to go about this.......... $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { if(is_null ($_FILES['imagen'])) { $imagen = $row_Recordset1['imagen']; // supplies the form with the original photo } else { $imagen=subir($image); // supplies the query with the new photo } $colaborador=$_POST['colaborador']; $pk=$_POST['hiddenField']; $updateSQL = sprintf("UPDATE colaboraciones SET imagen='$imagen', colaborador='$colaborador' WHERE pk='$pk';"); mysql_select_db($database_connect, $connect); $Result1 = mysql_query($updateSQL, $connect) or die(mysql_error()); I know I'm doing this very backwards and probably harder than it needs to be, but for right now I'd be content with getting this working. Thanks for any and all help! Quote Link to comment Share on other sites More sharing options...
liam1412 Posted September 10, 2007 Share Posted September 10, 2007 Just put it ina an if statement just use an ! if(!isset($uploadedimg)){ supply old photo } else { add new image } You could however just ignore the processing completely ie not supply the old image again. Not too much of an issue but just extra load on the server. But as you said thats how you do it the way you wan. replace is_null with ! Thanks Quote Link to comment Share on other sites More sharing options...
xyn Posted September 10, 2007 Share Posted September 10, 2007 i would use if(isset($_POST['file_upload'])) { # do your coder } # the rest here then if theres an image; upload it. if there isnt the code can process. Quote Link to comment Share on other sites More sharing options...
director87 Posted September 10, 2007 Author Share Posted September 10, 2007 Thanks for the post. I ended up using if(!is_uploaded_file($file_check)) { // old route of image } else { // upload new image } I never heard of the is_uploaded_file function, but it works like a charm. Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.