I have a uploader thats suppose to upload videos and pictures. When I try it, it says: Parse error: syntax error, unexpected T_IF, expecting ',' or ';' in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 9 My Php code is: <?php $target = "Videos/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; echo "Please wait while your file is uploaded.<br>" //This is our size condition if ($uploaded_size > 350000000) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type !="movie/*" or "image/*") { echo "No PHP<br>"; $ok=0; //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //This is our limit file type condition if ($uploaded_type =="text/ActiveX") { echo "No ActiveX<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type =="text/aspx") { echo "No ASPX<br>"; $ok=0; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "Your file has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } } ?> I am a newbie to php. Could somebody help me with this error and anything else that might be wrong with it?
Sure buddy, On line 7 there is a missing ; echo "Please wait while your file is uploaded.<br>"; The php parser runs into an error two lines below since the echo "bla bla" is not closed. Line 7: echo "Please wait while your file is uploaded.<br>" Line 8: Line 9: //This is our size condition Line 10: if ($uploaded_size > 350000000) PHP: The error message pretty much actually tells where the error is
on line 6 you haven't close the echo tag: echo "Please wait while your file is uploaded.<br>" Code (markup): change this to, changes are in bold: echo "Please wait while your file is uploaded.<br>"[B] ; [/B] Code (markup): there is one more error that you haven't closed one IF function: if ($uploaded_type !="movie/*" or "image/*") { echo "No PHP<br>"; $ok=0; Code (markup): I have solved the problems, here is the whole solved code: <?php $target = "Videos/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; echo "Please wait while your file is uploaded.<br>"; //This is our size condition if ($uploaded_size > 350000000) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type !="movie/*" or "image/*") { echo "No PHP<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //This is our limit file type condition if ($uploaded_type =="text/ActiveX") { echo "No ActiveX<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type =="text/aspx") { echo "No ASPX<br>"; $ok=0; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "Your file has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } } ?> PHP: Thanks!
That script has a security hole too, I think. If you upload a file ending in .PHP with valid movie headers, you could run php code.