Page 1 of 1

If Else troubles

Posted: Sun Nov 20, 2005 3:24 pm
by mhouldridge
Hi,

What seems a simple if else statement is not working. It is as follows;

Code: Select all

if (file_exists($userfile_name)) {
	echo "Error - The $userfile (name) already exists.  Please change the name of this file to something else and try again.";
	} 
else (move_uploaded_file($userfile, $add)) {
	echo "File uploaded, thankyou";
	}
Please help.

Posted: Sun Nov 20, 2005 4:01 pm
by mhouldridge
anyone???

Posted: Sun Nov 20, 2005 4:11 pm
by mhouldridge
I have sorted this now, however my first check file exist statement does not work,

Any ideas?

Here is the script.

Code: Select all

if (file_exists($userfile_name)) {
	echo "Error - Filename already exists.  Please change the name of this file to something else and try again.";
	} 
else {
	(move_uploaded_file($userfile, $add));
	echo "File uploaded, thankyou";
	}

Posted: Sun Nov 20, 2005 4:21 pm
by Nathaniel
$userfile_name and $userfile should both be the same variable, I believe...

Posted: Sun Nov 20, 2005 4:26 pm
by mhouldridge
sorted it now.

Posted: Sun Nov 20, 2005 4:26 pm
by AKA Panama Jack
Remove the parenthesis from this line

(move_uploaded_file($userfile, $add))

to

move_uploaded_file($userfile, $add)