cwademusic Posted March 16, 2007 Share Posted March 16, 2007 So i'm having all sorts of troubles just trying to get a simple file upload form up and running. I'm following a tutorial, so i've been using the script furnished by the tutorial author. I've scraped the message boards for information relating to the problems i've been having, but to no avail. I know it shouldn't be this difficult, so most likely it's a ; or ' missing in the script, but if someone could check it out and get back to me i will be ever so grateful (plus i'll be able to sleep soundly, as well). here's the script: <?php //*this is the path where the uploaded files will be stored $target_path = 'C:\Documents and Settings\Administrator\My Documents\Dreamweaver\uploads\'; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file( $_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } ?> and here is the immediate error message with this script (i've had many, as i've been changing things): Parse error: parse error, unexpected T_STRING in /home/cwademus/public_html/winupload.php on line 4 oh, and here's the HTML portion for the form: <form enctype="multipart/form-data" action="winupload.php" method="POST"> <p>Choose a file to upload: </p><input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form> thanks in advance! C Link to comment https://forums.phpfreaks.com/topic/42937-solved-parse-error/ Share on other sites More sharing options...
per1os Posted March 16, 2007 Share Posted March 16, 2007 $target_path = 'C:\Documents and Settings\Administrator\My Documents\Dreamweaver\uploads\'; SHOULD BE $target_path = 'C:\\Documents and Settings\\Administrator\\My Documents\\Dreamweaver\\uploads\\'; You need to double escape the \ as it is an escape character (IE: if you have $test = "<body bgcolor=\"#000000\">"; the \ makes the quote part of the string, so it "escapes it". Link to comment https://forums.phpfreaks.com/topic/42937-solved-parse-error/#findComment-208560 Share on other sites More sharing options...
cwademusic Posted March 16, 2007 Author Share Posted March 16, 2007 aha! that took care of the parse error. but unfortunately there are still more errors (this has been going on all day....) this error is now thrown up: Warning: move_uploaded_file(C:\Documents and Settings\Administrator\My Documents\Dreamweaver\uploads\popup code.txt): failed to open stream: Permission denied in /home/cwademus/public_html/winupload.php on line 6 Warning: move_uploaded_file(): Unable to move '/var/tmp/phpWFLCQl' to 'C:\Documents and Settings\Administrator\My Documents\Dreamweaver\uploads\popup code.txt' in /home/cwademus/public_html/winupload.php on line 6 There was an error uploading the file, please try again! Link to comment https://forums.phpfreaks.com/topic/42937-solved-parse-error/#findComment-208563 Share on other sites More sharing options...
per1os Posted March 16, 2007 Share Posted March 16, 2007 your target_path should be /home/cwademus/public_html/%insertuploadfoldernamehere% Your server does not understand the windows paths, even if the server is running on windows (which it seems to be running on *nix if you ask me) so in order to move that uploaded file it needs to be an absolute path on the server. If you are trying to save that file to your local box you would need to download it off the server after it was uploaded to the server. What exactly are you trying to do? Link to comment https://forums.phpfreaks.com/topic/42937-solved-parse-error/#findComment-208574 Share on other sites More sharing options...
cwademusic Posted March 16, 2007 Author Share Posted March 16, 2007 yeah, so i've tried the path you suggested, and am now receiving a different error message: Warning: move_uploaded_file(/home/cwademus/public_html/uploads/popup code.txt): failed to open stream: Permission denied in /home/cwademus/public_html/winupload.php on line 6 Warning: move_uploaded_file(): Unable to move '/var/tmp/phpWFLCQl' to '/home/cwademus/public_html/uploads/popup code.txt' in /home/cwademus/public_html/winupload.php on line 6 There was an error uploading the file, please try again! *popup code.txt is the file i'm trying for a test upload all i'm trying to accomplish here is to have a file stored onto my host server, so i may be able to download it at some point. --purely an educational endeavour on my part. i'm just trying to expand my horizons step by step in php and have apparently hit a brick wall! hahahaha. i've successfully set up a comments page, and form mail, and this should be cake compared to that... apparently not. doh! Link to comment https://forums.phpfreaks.com/topic/42937-solved-parse-error/#findComment-208587 Share on other sites More sharing options...
per1os Posted March 16, 2007 Share Posted March 16, 2007 You need to chmod the uploads folder to 777. Link to comment https://forums.phpfreaks.com/topic/42937-solved-parse-error/#findComment-208588 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.