Jump to content

redfinger
 Share

Recommended Posts

please why is this code not working <!DOCTYPE html><html><head> </head> <body><?php$allowedExts=array("gif","jpg","png","jpeg");$extension = end(explode(".",$_FILES["file"]["name"]));if ((( $_FILES["file"]["type"]=="image/png")|| ($_FILES["file"]["type"]=="image/jpg")|| ($_FILES["file"]["type"]=="image/jpeg")|| ($_FILES["file"]["type"]=="image/gif")|| ($_FILES["file"]["type"]=="image/x-png")|| ($_FILES["file"]["type"]=="image/pjpeg")&& ($_FILES["file"]["size"] < 20000)&& in_array ($extension, $allowedExts)) {if ($_FILES["file"]["error"] > 0){echo "error " . $_FILES["file"]["error"] . "<br>";}else{echo "Name " . $_FILES["file"]["name"] . "<br>";echo "Type " . $_FILES["file"]["type"] . "<br>";echo "Size " . ($_FILES["file"]["size"] /1024) . "<br>" ;echo "Stored in " . $_FILES["file"]["tmp_name"];}}else{echo "invalid file";} ?></body> </html> its giving this error Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\upload_script.php on line 19

Link to comment
Share on other sites

It throws that error because it's expecting a closing ')' before it gets to any other structures. -- You have too many '(' in your if structure.

Edited by Deirdre's Dad
Link to comment
Share on other sites

Oops. I typed too quickly, and I've corrected the error. Try changing this

if (((

to

if ((

Actually, you did somehow change the original. In moving this line, you dropped the second ')', which was the right thing to do to the line, but the ')' was there to close off the section containing all the '||' statements and probably should stay there.

|| ($_FILES["file"]["type"] == "image/png"))

Edited by Deirdre's Dad
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...