Jump to content

File Upload PHP Script


garygas

Recommended Posts

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)

[quote]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.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>
[/quote]

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

[quote]<?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 />;
}
}
?>[/quote]

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

[quote]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[/quote]

Anyone got any ideas as to what is wrong?

Thanks,

Gary
Link to comment
Share on other sites

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.