redfinger Posted June 5, 2013 Share Posted June 5, 2013 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 More sharing options...
jeffman Posted June 5, 2013 Share Posted June 5, 2013 (edited) 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 June 9, 2013 by Deirdre's Dad Link to comment Share on other sites More sharing options...
redfinger Posted June 9, 2013 Author Share Posted June 9, 2013 okay.l got that code from w3schools.com php section for uploding file.how can their code be wrong and if it is that means am..jeez..so pls wot should the code be Link to comment Share on other sites More sharing options...
jeffman Posted June 9, 2013 Share Posted June 9, 2013 (edited) 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 June 9, 2013 by Deirdre's Dad Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now