I am having issues uploading a file.  I am trying to up load a file from my
computer to the server so taht I can run a mysql query using the load data
infile query.  here is the code

<html>
<body>
<?PHP
        if (isset($users_file))
        {
                // connect to the database
                //database connection code

                echo "<B>Remote File Name:</B> $users_file<BR>";
                echo "<B>Local File Name:</B> $users_file_name<BR>";
                echo "<B>Local File Size:</B> $users_file_size<BR>";
                if (isset($users_file_type))
                {
                        echo "<B>Local File Type:</B> $users_file_type<P>"; 
                }

                // Change $doc_directory to your 'DocumentRoot'.
                $doc_directory = "/www/www.linuxguruz.org/htdocs/";
                $my_file = "tmp/uploaded-".$users_file_name;
                $copy_path = $doc_directory.$my_file;

                if ($users_file != "none")
                {
                        $query = "LOAD DATA LOCAL INFILE '$users_file' ";
                        $query .= "INTO TABLE `nrb_test` ";
                        $query .= "FIELDS TERMINATED BY ',' ENCLOSED BY '\"'
ESCAPED BY '\\\\' ";
                        $query .= "LINES TERMINATED BY '\r\n' ";
                        $query .= "IGNORE 1 LINES";
                        
                        echo "$query<BR>\n";

                        if(!$result = mysql_query($query))
                        {
                                echo "File upload failed!";
                        }
                        else
                        {
                                ?><A HREF="<?PHP echo $my_file; ?>">Upload
Complete!</A><?PHP
                        }
                }
                else
                {
                        echo "<P>You must select a file to upload!<P>"; ?>
                        <A HREF="<?PHP echo $PHP_SELF; ?>"><B>Back</B></A>
to the Upload Form
                        <?PHP
                }
        }

        else
        {
                ?>
                <form action="<? echo $PHP_SELF; ?>"
                 enctype="multipart/form-data" method="POST">
                <input type="hidden" name="MAX_FILE_SIZE" value="20000">
                <input type="file" name="users_file"><br>
                <input type="submit" value="Upload!">
                </form>
                <?PHP
        }
?>
</body>
</html>

When I submit the form at the bottom of the script, the $user_file variable
equals "none".  I am unable to figure out what is going on.  The variable
$users_file_name lists the file's name, but the $user_file is none and the
$user_file_size =0. 
 
Why is $user_file equal to none?  Any help will be greatly appreciated. 



 "The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from all
computers." 


Reply via email to