Jump to content


Photo

File Upload PHP Script


  • Please log in to reply
No replies to this topic

#1 garygas

garygas
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 25 September 2006 - 09:31 AM

Hi Guys!

I am having some trouble with an upload script. I think its correct but who knows, cos it does not seem to work.

I created a simple HTML page with the whole upload features on it (code below)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Upload Form</title>
</head>
<body>
<form action="do_upload.php" enctype="multipart/form-data" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="51200" />
<p><strong>File to Upload:</strong><input type="file" name="fileupload" /></p>
<p><input type="submit" value="Upload!" /></p>
</form>
</body>
</html>


Than I created the do_upload.php as refered to in the above script. (below)

<?php
$file_dir = "\fileuploader";
foreach($_FILES as $file_name => $file_array) {
echo "path: ".$file_array['tmp_name']."<br />\n";
echo "name: ".$file_array['name']."<br />\n";
echo "type: ".$file_array['type']."<br />\n";
echo "size: ".$file_array['size']."<br />\n";

if (is_uploaded_file($file_array['tmp_name'])) {
move_uploaded_file($file_array['tmp_name'],
"$file_dir/$file_array[name]") or dir ("Couldn't copy");
echo "file was moved!<br /><br />;
}
}
?>


But when I load it onto my webserver, and run it, I get the error:

Parse error: parse error, unexpected $end in e:\domains\g\garygasonline.co.uk\user\htdocs\test_server\file_uploads\do_upload.php on line 15


Anyone got any ideas as to what is wrong?

Thanks,

Gary




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users