wowcrofty Posted September 11, 2010 Share Posted September 11, 2010 I currently have the following script used on my site to upload files. When the linked web page executes it, however, I receive the infamous Parse Error - Unexpected '<' in x:/xxxx. The problem lies in Line 11 where I attempt to define a command that will display a message box to the user upon successful file upload. The syntax is not correct and I was hoping someone would be able to help me with it. Here is the contents of the PHP file. <?php // Where the file is going to be placed $target_path = $_SERVER['DOCUMENT_ROOT'] . "/file_uploads/"; /*Add the original filename to our target path. Result is "uploads/filename.extension"*/ $target_path=$target_path.basename($_FILES['file']['name']); //Move file to upload directory if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) { echo <script type="text/javascript">alert("Upload was successful. Thank you for your contribution")</script>; } else{ echo "There was a problem submitting the file. Plese try again!"; } ?> Thank you in advance for any help. Quote Link to comment Share on other sites More sharing options...
WatsonN Posted September 11, 2010 Share Posted September 11, 2010 change echo <script type="text/javascript">alert("Upload was successful. Thank you for your contribution")</script>; to echo '<script type="text/javascript">alert("Upload was successful. Thank you for your contribution")</script>'; Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted September 12, 2010 Share Posted September 12, 2010 echo "There was a problem submitting the file. Plese try again!"; and say Please instead of Plese : ) Quote Link to comment Share on other sites More sharing options...
coupe-r Posted September 12, 2010 Share Posted September 12, 2010 This has helped me but I have a question on how to re-direct from here. under my alert(), I have a header(Location). If I comment out the header(), the alert runs fine, otherwise it just runs the redirect. Is there a way that the alert will run and then when you press the OK button in the dialog box, the rest of the code below will run? Thanks as always. 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.