Mr Chris Posted January 24, 2008 Share Posted January 24, 2008 Hi, I've written a script which uploads files. Now I have an upload file and I want to check that something has been uploaded AND it's a jpg: //check file extensions $ext = $exts[count($exts) - 1]; } if (empty($_FILES['ufile']['tmp_name'][0])) || (strtolower($ext) != "jpg") { $error = "** Error: You forgot to upload a jpg! **"; The first condition to check there is a file there works, but there is a problem with the OR or the condition after can anyone help? It states Parse error: syntax error, unexpected T_BOOLEAN_OR Thanks Quote Link to comment https://forums.phpfreaks.com/topic/87512-help-with-or-condition/ Share on other sites More sharing options...
GingerRobot Posted January 24, 2008 Share Posted January 24, 2008 You've closed your if statement. You've one too many closing parenthesis. Try: } if (empty($_FILES['ufile']['tmp_name'][0]) || (strtolower($ext) != "jpg") { Quote Link to comment https://forums.phpfreaks.com/topic/87512-help-with-or-condition/#findComment-447623 Share on other sites More sharing options...
Mr Chris Posted January 24, 2008 Author Share Posted January 24, 2008 Thanks! Just one other thing. Now my condition checking is not working. It throws up $error even though you are uploading the correct extentions: $puzzle= "upload/$one".$_FILES['ufile']['name'][0]; $pdf= "upload/$two".$_FILES['ufile']['name'][1]; $png= "upload/$three".$_FILES['ufile']['name'][2]; //copy file to where you want to store file move_uploaded_file ($_FILES['ufile']['tmp_name'][0], $puzzle); move_uploaded_file($_FILES['ufile']['tmp_name'][1], $pdf); move_uploaded_file($_FILES['ufile']['tmp_name'][2], $png); //check file extensions $ext_puz = $puzzle[count($puzzle) - 1]; $ext_pdf = $pdf[count($pdf) - 1]; $ext_png = $png[count($png) - 1]; // ** Check for Required Fields with IF statements ** if (empty($title)){ $error = "** You forgot to enter a title **"; $flag=1; } if (empty($type)){ $error = "** Error: You forgot to enter the type of puzzle! **"; $flag=1; } if (empty($about)){ $error = "** Error: You forgot to enter any about info! **"; $flag=1; } if (empty($_FILES['ufile']['tmp_name'][0]) || (strtolower($ext_puz) != "jpz")) { $error = "** Error: You forgot to upload a puzzle file (jpz)! **"; $flag=1; } if (empty($_FILES['ufile']['tmp_name'][1]) || (strtolower($ext_pdf) != "pdf")) { $error = "** Error: You forgot to upload a pdf! **"; $flag=1; } if (empty($_FILES['ufile']['tmp_name'][2]) || (strtolower($ext_png) != "png")) { $error = "** Error: You forgot to upload a png solution file! **"; $flag=1; } I'm a bit stumped! Quote Link to comment https://forums.phpfreaks.com/topic/87512-help-with-or-condition/#findComment-447631 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.