File upload with mysql and php
<p>OK I decided to retry it into another way.. This is my code the bad part is now it keep saying invalid file size.</p>

<pre><code>&lt;?php
      session_start();
      include "connect.php";
      if ( $_POST[ "submit" ] ) {
             if ( $_SESSION[ "name" ] ) {
                    $name = $_FILES[ "file" ][ "name" ];
                    $type = $_FILES[ "file" ][ "type" ];
                    $size = $_FILES[ "file" ][ "size" ];
                    $tmp_name = $_FILES[ "file" ][ "tmp_name" ];
                    $error = $_FILES[ "file" ][ "error" ];
                    if ( $type == "image/jpeg" || $type == "image/gif" ) {
                           if ( $size &gt; 1100000 &amp;&amp; $size &lt; 1700000 ) {
                                  if ( $error &gt; 0 ) {
                                         echo "Error!!!!!!" . $error;
                                  } else {
                                         if ( file_exists( "upload/" . $name ) ) {
                                                echo $name . " already exists.";
                                         }
                                  }
                           } else {
                                  $location = "upload/" . $name;
                                  move_uploaded_file( $tmp_name , $location );
                                  $user = $_SESSION[ "name" ];
                                  $sqlcode = mysql_query( "INSERT INTO tblFile (id,user,location) VALUES ('','$user','$location')" );
                                  echo "&lt;a href='$location'&gt;Click here to view your image.&lt;/a&gt;";
                           }
                    }
             } else {

                    echo "Please check the size of your File..";
             }
      } else {
             echo "Invalid file format.";
      }

 ?&gt;
</code></pre>

<p>the index is:</p>

<pre><code>&lt;?php

session_start();
$_SESSION["name"] = "Admin";

?&gt;


&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
&lt;head&gt;
    &lt;title&gt;File Upload&lt;/title&gt;
&lt;link href="styles.css" type="text/css" rel="stylesheet" /&gt;
&lt;/head&gt;
&lt;body&gt;


&lt;form enctype="multipart/form-data" action="upload.php" method="post"&gt;

Select File: &lt;input type="file" name="uploadFile"&gt;
&lt;input type="hidden" name="MAX_FILE_SIZE" value="1000000"/&gt;
&lt;input name="Submit" type="submit" value="Upload File"&gt;

&lt;/form&gt;
</code></pre>

<p>If it is not one thing with this file/upload it is something else. I still have to be able to   user uploads a .png or .jpg file, resize the image to a thumbnail and keep a copy of both the thumbnail and regular size image in a folder. And be able to insert the data into a new table in your database. I think I am alittle closer than before.</p>
