Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Upload file error

Hi,

I'm using apache2 on ubuntu (the ubuntu is located inside vmware) host is win7

my plan was creating an upload file page so that it could store my file..

following are my codes //upload.html - (i eventually didnt insert the "<" as it wont come out) action="upload.php" method="post" enctype="multipart/form-data" nput type="file" name="filename" /> input type="submit" value="Upload" /> /form>

//separated file, upload.php <?php $print_r($_HTTP_POST_FILES); $folder = “/var/www/uploading/”; 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.”; }; ?>

seems error as i got the 500 internal server message; //from access.log 192.168.145.1 - - [29/Nov/2013:21:48:33 -0800] "POST /upload.php HTTP/1.1" 500 275 "http://192.168.145.131/upload.html" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36"

//from error.log "[Fri Nov 29 21:54:40 2013] [error] [client 192.168.145.1] PHP Parse error: syntax error, unexpected T_VAR in /var/www/upload.php on line 4, referer: http://192.168.145.131/upload.html?

my coding is all located at /var/www/ --> i'm also #root at the moment i also created folder name uploading (chmod 777 uploading/)

Please help TQ

2 Answers

//the upload.html file

<form action="upload.php" method="post" enctype="multipart/form-data"> File: <input type="file" name="filename" /> <input type="submit" value="Upload" /> </form>

Hi, no answer? :(