aelouch Posted November 20, 2013 Share Posted November 20, 2013 Hello I am trying to get the following script to work for uploading images to my websites images folder but keep getting the following error. Parse error: syntax error, unexpected T_VARIABLE in /home/a9865238/public_html/uploads/upload.php on line 3 =============================================================================================== upload.html =============================================================================================== <form action="upload.php" method="post" enctype="multipart/form-data"> File: <input type="file" name="filename" /> <input type="submit" value="Upload" /> </form> =============================================================================================== upload.php =============================================================================================== <?php $folder = “/home/a9865238/public_html/images/”; if (is_uploaded_file($HTTP_POST_$FILES['filename']['tmp_name'])) { if (move_uploaded_file($HTTP_POST_$FILES['filename']['tmp_name'], $folder.$HTTP_POST_FILES['filename']['name'])) { Echo “File uploaded”; } else { Echo “File not moved to destination folder. Check permissions”; }; } else { Echo “File is not uploaded.”; $name=$_FILES['file']["name"]; $path=$_FILES['file']["tmp_name"]; $destination="upload/".$name; move_uploaded_file($path,$destination)?"file moved":"file not moved"; }; ?> Regards Ant Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted November 20, 2013 Share Posted November 20, 2013 (edited) You are using fancy quotes $folder = “/home/a9865238/public_html/images/”; Change the quotes $folder = "/home/a9865238/public_html/images/"; You have to pay attention to the correct quotes when copying code from websites. Edited November 20, 2013 by QuickOldCar Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted November 21, 2013 Share Posted November 21, 2013 This $HTTP_POST_$FILES should be $HTTP_POST_FILES Well, technically $HTTP_POST_FILES has been depreciated, you should review the following: http://php.net/manual/en/reserved.variables.files.php Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted November 21, 2013 Share Posted November 21, 2013 There was more, also you don't need a semicolon after the curly braces. <?php $folder = "/home/a9865238/public_html/images/"; if (is_uploaded_file($HTTP_POST_$FILES['filename']['tmp_name'])) { if (move_uploaded_file($HTTP_POST_$FILES['filename']['tmp_name'], $folder.$HTTP_POST_FILES['filename']['name'])) { Echo "File uploaded"; } else { Echo "File not moved to destination folder. Check permissions"; } } else { Echo "File is not uploaded."; $name=$_FILES['file']["name"]; $path=$_FILES['file']["tmp_name"]; $destination="upload/".$name; move_uploaded_file($path,$destination)?"file moved":"file not moved"; } ?> Quote Link to comment 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.