I am receiving an error with this code. I am new to PHP but it is my understanding that || is translated to ‘OR’. I am trying to check if the uploaded file meets any of the three conditions, and if so set an error.
if ($uploaded_size > 1048576) ||
($uploaded_type == 'application/octet-stream') ||
(file_exists($target))
{
echo "Error: File was not uploaded.<br>";
$ok=0;
}
The error states that “unexpected T_BOOLEAN_OR”
Notice that you end the
ifstatement with a)before the||, so the||is just sitting outside by itself. You’re also missing a parenthesis between(file_exists($target))
and the{.You probably want this:
Or the equivalent: