Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/87512-help-with-or-condition/
Share on other sites

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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.