cannot read form variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thosecars82
Forum Commoner
Posts: 94
Joined: Thu Apr 03, 2008 6:31 am
Location: Arganda, Madrid
Contact:

cannot read form variable

Post by thosecars82 »

Hello, do you have any idea to be able to read the send variable of the form?
Altough I browse a file, it still does not show anything in the echo marked with asterisks below.thks in advance

<!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>Untitled Document</title>
</head>

<body>
<?PHP
if ($_POST['send']) {
echo "upfile = ".$_POST['upfile'];// ********* I don't know why this line does not print the name of the //choosen upfile. It's
// as if the variable upfile of the form could not be readed. Moreover, the following if conditions
//obviously cannot work until I solve this issue.
if ($_POST['upfile'] != "none" AND $_POST['upfile_size'] != 0){
echo "Name: ".$_POST['upfile_name']."<BR>\n";
echo "Size: ".$_POST['upfile_size']." <BR>\n";
echo "Type: ".$_POST['upfile_type']." <BR>\n";

// for Windows
if (! copy ($_POST['file'], "C:\\TEMP\\".$_POST['upfile_name'])) {
echo "<h2>File could not be copied</h2>\n";
}

/* for Linux/Unix
if (! copy ($_POST['file'], "/tmp/".$_POST['file_name'])) {
echo "<h2>File could not be copied</h2>\n";
}
} */
}
elseif (($_POST['upfile'] != "none") AND ($_POST['upfile_size'] == 0)) {
echo "<h2>File size exceded exceded</h2>\n";
}
else {
echo "<h2>You haven't choose a new file to upload</h2>\n";
}
echo "<HR>\n";
}
?>
<FORM ENCTYPE="multipart/form-data" ACTION="<?php echo $PHP_SELF ?>" METHOD="post">
<INPUT type="hidden" name="MAX_FILE_SIZE" value="100000">
<p><b>File to upload<b><br>
Example
<INPUT type="file" name="upfile" size="35"></p>
<p><INPUT type="submit" name="send" value="Accept"></p>
</FORM>
</body>
</html>
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: cannot read form variable

Post by Christopher »

(#10850)
thosecars82
Forum Commoner
Posts: 94
Joined: Thu Apr 03, 2008 6:31 am
Location: Arganda, Madrid
Contact:

Re: cannot read form variable

Post by thosecars82 »

thks
it's solved as it's said where u told me
$_FILES['upfile']['name']
Post Reply