MadnessRed Posted June 19, 2008 Share Posted June 19, 2008 I have an upload script which for some reason just shows this error Parse error: syntax error, unexpected '{' in /home/www/uploadfile.php on line 27 I have two files 1 - The form (this page is access view "page.php?page=upload" and SSI is included in page.php" <?php echo'<html><head>' ?> <title> MadnessRed.co.cc :: Upload File </title> <?php include("includetop.php"); ?> <?php include("normalbody.php"); ?> <br /> <?php if ($context['user']['is_guest']) { echo '<h3>Sorry, for security reason we are only allowing registered user to upload files. Sorry for the inconvenience.</h3><br>'; ssi_login(); } else { echo 'Welcome to the file upload page. Please note that we only allow jpeg images under 1mb at the moment. All uploaded files will be given the prefix "'; echo $context['user']['name']; echo '_".<br /><br /> <form enctype="multipart/form-data" action="uploadfile.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000" /> Choose a file to upload: <input name="uploaded" type="file" /><br /> Choose a category: <select name="category"> <option value="pics">Images</option> </select><br /> <input type="submit" value="Upload" /> </form> '; } ?> <?php include("includebottom.php"); ?> 2 - The script <?php include("includessi.php"); ?> <html> <head> <title> MadnessRed.co.cc :: Upload File </title> <?php include("includetop.php"); ?> <?php include("normalbody.php"); ?> <br /> <?php //Lets find out what this file is for, Images? $category = $_POST["category"]; //Now lets see, who uploaded the file $name = $context['user']['name']; //Now lets see how many errors there were, hopefully none. $numerrors = $_FILES['uploaded']['error']; //Сheck that we have a file if (!empty($_FILES["uploaded"]) { if ($_FILES['uploaded']['error'] == 0) { //Check if the file is JPEG image and it's size is less than 1000Kb $filename = basename($_FILES['uploaded']['name']); $ext = substr($filename, strrpos($filename, '.') + 1); if (($ext == "jpg") && ($_FILES["uploaded"]["type"] == "image/jpeg") && ($_FILES["uploaded"]["size"] < 1000000)) { //Determine the path to which we want to save this file $newname = dirname(__FILE__).'/Images/'.$catagory.'/'.$name.'_'.$filename; //Check if the file with the same name is already exists on the server if (!file_exists($newname)) { //Attempt to move the uploaded file to it's new place if ((move_uploaded_file($_FILES['uploaded']['tmp_name'],$newname))) { echo "It's done! You image has been saved in: ".$category."."; } else { echo "Error: A problem occurred during file upload!"; } } else { echo "Error: File ".$_FILES["uploaded"]["name"]." already exists"; } } else { echo "Error: Only .jpg images under 1mb are accepted for upload. We will allow other image types later"; } } else { echo $numerrors." Errors: No file uploaded"; } } else { echo "Error: No file selected, upload field contained no files."; } ?> <?php include("includebottom.php"); ?> Link to comment https://forums.phpfreaks.com/topic/110955-parse-error-syntax-error-unexpected/ Share on other sites More sharing options...
revraz Posted June 19, 2008 Share Posted June 19, 2008 What is: line 27 in uploadfile.php and which one is uploadfile.php I noticed this right away in your 2nd file if (!empty($_FILES["uploaded"]) You're missing a ) at the end. Link to comment https://forums.phpfreaks.com/topic/110955-parse-error-syntax-error-unexpected/#findComment-569224 Share on other sites More sharing options...
MadnessRed Posted June 19, 2008 Author Share Posted June 19, 2008 thanks, it works! Link to comment https://forums.phpfreaks.com/topic/110955-parse-error-syntax-error-unexpected/#findComment-569226 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.