Image Submission into a Database & Updating

From: Date: Thu, 19 Jul 2001 22:01:58 +0000
Subject: Image Submission into a Database & Updating
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-58794@lists.php.net to get a copy of this message
Ok.. I have created a submission form that works great just like what I want.. but there is one minor detail if possible to figure out. When I let users upload a photo to my site, the image will be stored on the server hdd and the name of the image will be stored in the database. Works great!.. but lets say they submit another image in the same form.. it will overwrite the image name in the database, and uploads the new image.. but what about the old one? It stays dorment unusable and taking up space on my hdd. So... my question is.. what line can I add to delete the image before or after uploading the new one. I mean you can make the old name value into a temp value, and then it will overwrite the original value and you still have the temp value.. I think.. here is what by submit code looks like. Hopefully someone can figure this out. -------------code : if ($submit) { $connection = mysql_pconnect(SQL_SERVER, SQL_UID, SQL_PWD); mysql_select_db(SQL_DB, $connection); $sql = "UPDATE user SET desc_one='".addslashes($desc_one)."',photo_one='".addslashes($picture_name). "' WHERE userid='userid'"; mysql_query($sql); exec("cp $picture /root/lets/play/folder/tag/images/$picture_name"); return 0; } -------------code end. Thanks BradC

« previous php.general (#58794) next »