Jump to content

Need homework help files wont upload.


Go to solution Solved by Ch0cu3r,

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

  • Solution

 

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.

  • Like 1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.