Uploaded File OverWriting Old File

From: Date: Sat, 11 May 2002 10:04:01 +0000
Subject: Uploaded File OverWriting Old File
Groups: php.general 
Request: Send a blank email to php-general+get-97077@lists.php.net to get a copy of this message
Hi, If i have a filename "room.jpg" in my Upload Directory, and someone else comes and uploads a file by the same name, the previous "room.jpg" is overwritten by the new one. Any suggestions? This is the code i'm using : <?php $db = mysql_connect("localhost","user","pwd"); mysql_select_db("dbname",$db); if ($img1_name != "") { $pic = "yes"; } else { $pic = "no"; } $date = date("l dS of F Y h:i:s A"); // if $img_name isn't empty, try to copy the file if (($img1_name != "") and ($img1_size <= "256000") and ($img1_type == "image/pjpeg") or ($img1_type == "image/jpeg")) { $sql = "INSERT INTO tablename (name,age,gender,country,email,date,profile,looking,pic_name,pic) VALUES ('$name','$age','$gender','$country','$email','$date','$profile','$looking','$img1_name','$pic')"; $result = mysql_query($sql) or die("You made a mistake, please go back and try again"); copy("$img1", "mjpalpics/$img1_name") or Die ("Could not do"); } ?> Thank you for adding you details. The following has been added to the Database :<br><br> <big> <?php $profile = stripslashes("$profile"); $looking = stripslashes("$looking"); echo (" Name : $name<br> Age : $age<br> Gender : $gender<br> Country : $country<br> Email : $email<br> Your Profile : $profile<br> You are looking for : $looking<br> "); if (($img1_size <= "256000") and ($img1_type == "image/pjpeg") or ($img1_type == "image/jpeg")) { echo " Your Photo : <i>Name - $img1_name | Size - $img1_size | MIME Type - $img1_type</i> <br> "; } else { echo "No photograph uploaded, or wrong Type/Size photograph"; } ?> Thanks a LOT! T. Edison jr. ===== Rahul S. Johari (Director) ****************************************** Abraxas Technologies Inc. Homepage : http://www.abraxastech.com Email : abraxastech@yahoo.com Tel : 91-4546512/4522124 ******************************************* __________________________________________________ Do You Yahoo!? LAUNCH - Your Yahoo! Music Experience http://launch.yahoo.com

« previous php.general (#97077) next »