Re: Uploaded File OverWriting Old File

From: Date: Sat, 11 May 2002 10:49:39 +0000
Subject: Re: Uploaded File OverWriting Old File
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-97082@lists.php.net to get a copy of this message
Glory & Power! I'm using the following code now... the Error is gone, but it's still overwriting the old file. It's not changing the name.. not doing anything, just uploading this new file and replacing the old one.. <?php $db = mysql_connect("localhost","use","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")) { if(file_exists($img1_name)) { $img1_name = "n"+$img1_name; } $sql = "INSERT INTO mjpals (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"); } elseif (($img1_name == "") and ($img1_size > "256000") and ($img1_type != "image/pjpeg") or ($img1_type != "image/jpeg")) { $sql = "INSERT INTO mjpals (name,age,gender,country,email,date,profile,looking,pic_name,pic) VALUES ('$name','$age','$gender','$country','$email','$date','$profile','$looking','','no')"; $result = mysql_query($sql) or die("You made a mistake, please go back and try again"); } ?> 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"; } ?> ===== 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 (#97082) next »