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 Link to comment https://forums.phpfreaks.com/topic/284119-image-upload-script-issue/ Share on other sites More sharing options...
QuickOldCar Posted November 20, 2013 Share Posted November 20, 2013 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. Link to comment https://forums.phpfreaks.com/topic/284119-image-upload-script-issue/#findComment-1459285 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 Link to comment https://forums.phpfreaks.com/topic/284119-image-upload-script-issue/#findComment-1459286 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"; } ?> Link to comment https://forums.phpfreaks.com/topic/284119-image-upload-script-issue/#findComment-1459287 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.