![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Programmer
Join Date: Jan 2005
Location: Albany, NY
Posts: 43
Rep Power: 0
![]() |
file_exists() problemo
We'll I'm programming a file uploader with php. I found a simple script on the net and I'm adding onto it. I've run into a problem though, my if statement that contains my file_exists check isn't working. Heres the code I have:
<?php $filename = str_replace(' ', '', $_FILES['upload_file']['name']); $tblw = strlen($filename); $ext = substr($filename, $tblw-3, $tblw); $filesize= $HTTP_POST_FILES['upload_file']['size']; $name= $_POST['FName']; $stripName= strip_tags($name); if ($filesize > 262144) { echo "Sorry your file size is to big!"; echo "<br />"; echo "File size limit is 262144 bytes (or .25 MB)"; } if ($filesize = 0) { echo "No file was uploaded!"; } if (file_exists("/upload/".$stripName)) { echo "A file with this exact name already exists. Please go back and rename your file!"; } if ($ext == 'png' OR $ext == 'gif' OR $ext == 'jpg' || $filesize <= 262144 || $filesize != 0 || !file_exists("/upload/".$stripName)) { $uploaddir = "htdocs/upload/"; $uploadfile = $uploaddir . $stripName . "." . $ext; $file = 'htdocs/upload/' . $stripName . '.' . $ext; move_uploaded_file($_FILES['upload_file']['tmp_name'], $uploadfile); echo "File was uploaded successfully!"; }; ?> Basically I want it so that if a file with the same name tries to get uploaded to my "upload" folder, then and error message comes up. But, for some reason, if the file exists, it just says "file was uploaded sucessfully", and doesn't overwrite the file that was already there? Any help is apperciated! |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|