is_upload_file problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ssand
Forum Commoner
Posts: 72
Joined: Sat Jun 22, 2002 9:25 pm
Location: Iowa

is_upload_file problem

Post by ssand »

Hi all,

I am trying to get a simple upload page to work and one of the problems I am having is checking to see if the file already exists.

Code: Select all

Currently using:

	if (!is_uploaded_file($userfile))
		{
			$error="Upload Problem: possible file attack.";
			echo "<font class=maintext>$error</font>";
			exit;
		&#125;
Which doesn't seem to work - as it lets multiple uploads of the same file name. Do I need to specify the path to the uploads dir somewhere within this code (/usr/local/apache/htdocs/apcenter/uploads/)?

Or is this not really the best way to check for an existing file before uploading?

Thanks - Steve
fatalcure
Forum Contributor
Posts: 141
Joined: Thu Jul 04, 2002 12:57 pm
Contact:

Post by fatalcure »

ur using the wrong code to check if a file exists ;)

Code: Select all

if (file_exists($userfile)) echo "File Already Exists...";
else &#123;
    //upload it here
&#125;
:)
ssand
Forum Commoner
Posts: 72
Joined: Sat Jun 22, 2002 9:25 pm
Location: Iowa

Thanks

Post by ssand »

Thanks! Works great. :D

Steve
Post Reply