Checking file_exists()
| From: | PHP Junkie | Date: | Wed, 15 Sep 2004 19:05:02 +0000 |
| Subject: | Checking file_exists() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-196772@lists.php.net to get a copy of this message | ||
Ave,
I have a simple file upload form, which uploads without a problem.
Today I added the file_exists() function to my PHP code. And everything
stopped working. What am I doing wrong here:
<?php
if($upload_file) {
$db = mysql_connect("localhost","usr","pwd");
mysql_select_db("imsafm",$db);
$date = date("m-d-Y, D, H:i");
$trauma = 'imsafm/$PHP_login/$img1_name';
if (file_exists($trauma)) {
echo "The file $img1_name already exists. Please choose a different
name.";
}
else {
$sql = "INSERT INTO file (login,filename,descr,size,uppedby,date) VALUES
('$PHP_login','$img1_name','$desc','$img1_size','$PHP_login','$date')";
$result = mysql_query($sql) or die("There is a problem.");
copy("$img1", "imsafm/$PHP_login/$img1_name") or die("Could not do");
echo "<br><b><i><small>File $img1_name uploaded to $PHP_login
folder.</small></i></b><br>";
}
}
?>
I'm not getting any errors (for some reason I don't on my MAC browser, just
a blank white page whenever PHP doesn't work).
Thanks.