Jump to content

Need homework help files wont upload.


dhmyers82

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/294989-need-homework-help-files-wont-upload/
Share on other sites

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.