dhmyers82 Posted March 1, 2015 Share Posted March 1, 2015 There has to be an error in the php that I am not seeing as I am getting php script echoed in the top of the document. Also It is not finding the server. I dont know if this is becaus of the error I can't find or something else. Yes I know it is in XHTML. I am using an outdated book. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "html://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>[TEMPLATE]</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> </head> <body> <?php error_reporting(E_ALL); ini_set('display_errors', 'on'); $dir = "files"; if (isset($_POST['upload'])) { if (isset($_FILES['new_file'])) { if (move_uploaded_file($_FILES['new_file']['tmp_name'], $dir. "/" .$_FILES['new_file']['name']) == True) { chmod($dir. "/" .$_FILES['new_file']['name'], 0644); echo "File \"" .htmlentities($_FILES['new_file']['name']). "\"successfully uploaded.<br />\n"; } else echo "There was an error uploading \"" .htmlentities($_FILES['new_file']['name']). "\".<br />\n"; } } ?> <form action="FileUploader.php" method="POST" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="25000" /><br /> File to upload:<br /> <input type="file" name="new_file" /><br /> (25000 byte limit) <br /> <input type="submit" name="upload" value="Upload the File" /> <br /> </form> </body> </html> Thank you for the help. Quote Link to comment https://forums.phpfreaks.com/topic/294989-need-homework-help-files-wont-upload/ Share on other sites More sharing options...
Solution Ch0cu3r Posted March 1, 2015 Solution Share Posted March 1, 2015 There has to be an error in the php that I am not seeing as I am getting php script echoed in the top of the document. If you are seeing the PHP code then either your server is not configured correctly, file does not end in .php extension or you are loading the file directly into the browser (address bar starts with file://). Can you tell use how you are testing the code? Yes I know it is in XHTML. I am using an outdated book. The version of HTML you use has no effect on PHP. 1 Quote Link to comment https://forums.phpfreaks.com/topic/294989-need-homework-help-files-wont-upload/#findComment-1507162 Share on other sites More sharing options...
dhmyers82 Posted March 1, 2015 Author Share Posted March 1, 2015 Thanks it was not saved as a .php and I know the HTML format has no bearing on it working. I have just had people tell me I need to be using HTML5 instead of XHTML, I was just trying to avoid more comments of that nature. Quote Link to comment https://forums.phpfreaks.com/topic/294989-need-homework-help-files-wont-upload/#findComment-1507163 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.