Missing Var

From: Date: Fri, 30 Jan 2004 02:22:56 +0000
Subject: Missing Var
Groups: php.general 
Request: Send a blank email to php-general+get-176289@lists.php.net to get a copy of this message
Running Red Hat Fedora 1, latest updates. MySQL 3.23.58 PHP 4.3.4 Apache 2.0.48. Uploaded file info not showing up where it's supposed to. Here's the scenario: Here is my "form header": <form enctype="multipart/form-data" action="includes/file.php" method="post"> <input type="hidden" name="usna" value="<?=$usna?>"> <input type="hidden" name="auth" value="<?=$auth?>"> <input type="hidden" name="filid" value="<?=$filid?>"> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> Here is the input field where it gets the filename: <input type=\"file\" name=\"finame\" size=\"27\"> Here is the PHP code that executes this: if($newfile){
       $uploaddir = "/home/nick/http/homepage/userfiles/";
       $uploadfile = $uploaddir . $_FILES['$finame']['name'];
if(move_uploaded_file($_FILES['$finame']['tmp_name'], $uploadfile)){
           $finame = basename($finame);
           $sql = mysql_query("INSERT INTO files SET filename='$finame', owner='$fiowner', description='$fidesc'");
       }
       else{
           echo "<p> </p><center><H2>File Upload Failed.</H2></center>";
            echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"5;URL=../index.php?index=main.inc&usna=$usna&auth=$auth\">";
       }
} Here is the resulting $_FILE values: Array ( [finame] => Array ( [name] => brian.txt [type] => text/plain [tmp_name] => /home/nick/dump/phpTFCF0R [error] => 0 [size] => 1627 ) ) Here is the resulting $uploadfile value, and the problem: /home/nick/http/homepage/userfiles/ Now, I took this code, as you might recognize parts of it, right from PHP.NET in the part of the manual about "post method uploads". I can't for the life of me figure out why the filename is not being returned to that string. Any thoughts? Nick

« previous php.general (#176289) next »