0

Here is a dub question. If this code is supposed to restrict files other than jpg, png and gif, why does it do it? This is for a file browser aplication. The image has to be one of the 3 accepted file extensions.

$ext - is the var that reads the file extensions, such as exe and so on.

if (($ext == "jpg" || "gif" || "png") && ($_FILES["uploaded_file"]["type"] == "image/jpeg" || "image/gif" || "image/png") && ($_FILES["uploaded_file"]["size"] < 1000000)){

echo 'something';

}else(
echo 'none';
)

I really don't see the mistake.

Edited by seularts: n/a

4
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by seularts
0

ok i am sorry but i can not understand the question. if there is an error what line and what message.

0

yeah, sorry i did not conclude that in my text.. well, when i load a, let's say, .txt file, it ignores the if statement and moves on, and i don't know why!?

0

Try the following:

$ext - is the var that reads the file extensions, such as exe and so on.

if (($ext == "jpg" || $ext=="gif" || $ext=="png") &&
($_FILES["uploaded_file"]["type"] == "image/jpeg" ||
$_FILES["uploaded_file"]["type"] == "image/gif" ||
$_FILES["uploaded_file"]["type"] == "image/png") &&
($_FILES["uploaded_file"]["size"] < 1000000)){

echo 'something';

}else(
echo 'none';
)

As you can see you had a few bugs.

0

Thanks, it worked, though my first form of the if statement worked before, but don't know why!?:)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.