Hello guys
Well, I've been trying to upload a file without much success so far. So I'm trying
to find the error but honestly this has become a real puzzle for me.
I�ve got the following form:
<form enctype=\"multipart/form-data\" name=\"book_add\" method=\"post\"
action=".$PHP_SELF."?management=8>
<table>
<tr><td class=\"nolink\">File to upload:</td>
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"2000\">
<td><input type=\"file\" name=\"formfile\"></td>
</tr>
</table>
The action thing just passes the results to a function for it to process the upload,
like this:
if ($management)
{
switch($management)
{
//Several cases
case 8:
do_upload_file($_POST, $_FILES)
break;
}
}
You may guess what the "do_upload_file" function is for, but all I'm doing at the
moment with it is trying to find out what the hell is going on here, so there it is:
function do_upload_file($_POST, $_FILES)
{
if (is_array($_FILES))
echo "$_FILES is ok<br>";
else
exit;
if (is_array($_POST))
echo "$_POST is ok<br>";
else
exit;
echo "File tmp_name: ".$_FILES['formfile']['tmp_name']."<br>";
echo "File size: ".$_FILES['formfile']['size']."<br>";
echo "File type: ".$_FILES['formfile']['type']."<br>";
echo "Error: ".$_FILES['formfile']['error'];
}
The results when trying to upload any kind of file but text/plain ones:
$_FILES is ok
$_POST is ok
File tmp_name: none
File size: 0
File type: application/pdf
Error:
As you can see the file type is being detected (I already tried with the most common
types: rtf, doc, xls, zip, ppt, pdf) but I'm getting nothing for name or size. I'm
also not getting any error message.
If I run the script with a text/plain file it goes through it without a problem.
I can't see an error in the way I am handling this upload thing, I also tried not
passing the values to a function but doing it directly in the case statement with the
same results.
Does anyone have a good idea of what's going on here? Hope someone does for I just
run out of ideas.
Thanks a lot
*******************************************************
Wilmar P�rez
Network Administrator
Library System
Tel: ++57(4)2105962
University of Antioquia
Medell�n - Colombia
2002
*******************************************************
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php