psyget Posted October 22, 2008 Share Posted October 22, 2008 hey everyone! I have an PHP script the uploads an image and sends the path to a mySQL db, it's working fine, the code is below, but i'm having problems with the edit form i'm doing... i can't get it to work... could somebody help me? see the code below: // up here i've declared my variables cause i'm inserting more stuff into the db, and i have a function called getExtension. i just didn't put them here so the post won't be huge ^^ // verifies if the image field is empty; if so, asigns the string 'images/blank.png' to the variable $newname if (empty($logo)) { $newname="images/blank.png"; $copied = copy($_FILES['logo']['tmp_name'], $newname); } else { // verifies if the image is a valid type if ($logo) { $filename = stripslashes($_FILES['logo']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { echo '<h1>Unknown file extension!</h1>'; $errors=1; } else { $size=filesize($_FILES['logo']['tmp_name']); // verifies if the size exceeds the maximum size limit if ($size > MAX_SIZE*1024) { echo '<h1>The size of the image exceeds the limit size!</h1>'; $errors=1; } // modifies the name of the image and adds the sulfix '_logo', so there won't be duplicates and copies it to the folder 'images' $image_name=time().'_logo.'.$extension; $newname="images/".$image_name; $copied = copy($_FILES['logo']['tmp_name'], $newname); if (!$copied) { echo '<h1>There were some errors and the files wasn't updated!</h1>'; $errors=1; }}}} then after that it puts the information inside the mySQL db... till there it's working really fine. How what i wanna do is the following: i have an edit form, which is supposed to show the information sent to the db and i wanna update it. If the person leaves the file field blank, i want to keep the same value that's is already in the db. If the person chooses another image, i want it to perform the exact same process as above, and replace the $newname value that was inserted into the db... but as i said, i'm no expert, i really new to PHP... could somebody help me please? i'd appreciate very much! thanks in advantage! Rennato [email protected] Link to comment https://forums.phpfreaks.com/topic/129628-problems-uploading-image-and-updating-mysql/ Share on other sites More sharing options...
elis Posted October 22, 2008 Share Posted October 22, 2008 Are you receiving any errors? Link to comment https://forums.phpfreaks.com/topic/129628-problems-uploading-image-and-updating-mysql/#findComment-672084 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.