why no $_POST[fupload] ?

C

carlton

When I run the following page, the foreach ($_POST as $key=>$value)
lists the correct values for MAX_FILE_SIZE and password, but no value
for fupload, why is the requested file not being sent? I have tried it
with Firefox, Opera, IE, and Konqueror. all with the same result.
I am running Mandriva 2006 with Apache 2.0.54
T.I.A.,
Carlton
<html>
<head>
<title>Listing 9.15 A file upload script</title>
</head>
<SCRIPT language="php">
<?php
$file_dir = "/home/carlton/uploads";
$file_url = "http://localhost/uploads";
foreach ($_POST as $key=>$value)
{
print "\$_POST[\"$key\"] == $value<BR> ";
}
if ( isset( $fupload ) )
{
print "path: $fupload<br>";
print "name: $fupload_name<br>\n";
print "size: $fupload_size bytes<br>\n";
print "type: $fupload_type<p>\n\n";
if ( $fupload_type == "image/gif" )
{
copy ( $fupload, "$file_dir/$fupload_name") or die ("Couldn't copy");

print "<img src=\"$file_url/$fupload_name\"><p>\n\n";
}
}
else
{
print"<BOLD>First call to the page</BOLD>";
}
?>
</SCRIPT>
<body>
<form enctype="multipart/form-data" action="" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="51200">
<input type="file" name="fupload"><br>
x<input type="submit" value="Send file!">
</form>
</body>
</html>
 
T

Toby Inkster

carlton said:
When I run the following page, the foreach ($_POST as $key=>$value)
lists the correct values for MAX_FILE_SIZE and password, but no value
for fupload, why is the requested file not being sent?

Same reason there's no $_COOKIE[fupload], $_GET[fupload], $_SERVER[fupload]
or $_SESSION[fupload].

The reason is: because that's not where uploaded files live.

Uploaded files live in $_FILES.

http://uk2.php.net/manual/en/features.file-upload.php
 
C

carlton

Toby said:
carlton wrote:

When I run the following page, the foreach ($_POST as $key=>$value)
lists the correct values for MAX_FILE_SIZE and password, but no value
for fupload, why is the requested file not being sent?


Same reason there's no $_COOKIE[fupload], $_GET[fupload], $_SERVER[fupload]
or $_SESSION[fupload].

The reason is: because that's not where uploaded files live.

Uploaded files live in $_FILES.

http://uk2.php.net/manual/en/features.file-upload.php
Thanks very much for the help, much appreciated. I had taken the code
from a php text book, so I assumed it was OK.
Carlton.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top