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.

What is the error you are getting or what is it doing when you use it?

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

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!?

can i see all of your code.

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.