thosecars82 Posted April 5, 2008 Share Posted April 5, 2008 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> Link to comment https://forums.phpfreaks.com/topic/99740-cannot-read-form-variable/ Share on other sites More sharing options...
pocobueno1388 Posted April 5, 2008 Share Posted April 5, 2008 You need to use the $_FILES variable. echo "upfile = ".$_FILES['upfile']['name']; More info here: http://us3.php.net/features.file-upload Link to comment https://forums.phpfreaks.com/topic/99740-cannot-read-form-variable/#findComment-510166 Share on other sites More sharing options...
thosecars82 Posted April 5, 2008 Author Share Posted April 5, 2008 thks a lot Link to comment https://forums.phpfreaks.com/topic/99740-cannot-read-form-variable/#findComment-510170 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.