title: Form data on load of Blueimp jQuery File Upload
body: <p>It seems that I have looked everywhere and tried everything and I can not get this to work, any help would be much appreciated! I am using Blueimp's jQuery File Upload. I have changed the UploadHandler.php in the following ways to make this upload work with multiple records and places within my system. I am using PHP and MySQL.</p>
  
  <p>Added to handle_file_upload function so that the file path, file name, file type, file size, the record type, and the "job number" is uploaded to a table I created in MySQL for each different file.</p>
  
  <pre><code>$file-&gt;upload_to_db = $this-&gt;add_file($job_num, $recordtype, $file_path, $filename, $type, $file_size);
  </code></pre>
  
  <p>This job number is sent to the page (with the file upload) as a get variable as well as a hidden form field to send to the Handler when adding a file. The add_file function I added is as follows:</p>
  
  <pre><code>function add_file($job_num, $recordtype, $filepath, $filename, $filetype, $filesize)
  {
      $filepath = addslashes($filepath);
      $insert_query = $this-&gt;query("INSERT INTO fileupload (job_num, recordtype, file_path, file_name, file_type, file_size) VALUES ('".$job_num."','".$recordtype."','".$filepath."','".$filename."','".$filetype."','".$filesize."')");
      return $insert_query;
  }
  </code></pre>
  
  <p>The query function:</p>
  
  <pre><code>protected function query($query) {
      $database = $this-&gt;options['database'];
      $host = $this-&gt;options['host'];
      $username = $this-&gt;options['username']; 
      $password = $this-&gt;options['password'];
      $Link = mysql_connect($host, $username, $password);
      if (!$Link){
          die( mysql_error() );
      }
      $db_selected = mysql_select_db($database);
      if (!$db_selected){
          die( mysql_error() );
      }
      $result = mysql_query($query);
      mysql_close($Link);
      return $result;
  }
  </code></pre>
  
  <p>I have a function for the delete as well. Now, this all works fine. Every file I add is saved and the path is stored in the database. From here I had to find a way to only show the files uploaded for that record instead of showing all files for every record. I modified the get function:</p>
  
  <pre><code>public function get($print_response = true) {
        if ($print_response &amp;&amp; isset($_GET['download'])) {
          return $this-&gt;download();
      }
      $uploads = $this-&gt;query_db();
      return $this-&gt;generate_response($uploads, $print_response);
  }
  </code></pre>
  
  <p>The query_db function:</p>
  
  <pre><code>public function query_db() {
      $uploads_array = array();
      // error_log("Job Num: ".$this-&gt;job_num."\n\n",3,"error_log.txt");
      $select_result = $this-&gt;query("SELECT * FROM fileupload WHERE job_num=423424");
      while($query_results = mysql_fetch_object($select_result))
      {   
          $file = new stdClass();
          $file-&gt;id = $query_results-&gt;id;
          $file-&gt;name = $query_results-&gt;file_name;
          $file-&gt;size = $query_results-&gt;file_size;
          $file-&gt;type = $query_results-&gt;file_type;
          $file-&gt;url = "filepath_to_url/".$query_results-&gt;file_name;
          $file-&gt;thumbnail_url = "filepath_to_thumbnail/".$query_results-&gt;file_name;
          $file-&gt;delete_url = "";
          $file-&gt;delete_type = "DELETE";
          array_push($uploads_array,$file);
      }
      return $uploads_array;
  }
  </code></pre>
  
  <p>Where the filepath is correct on my system. This, again, works just fine. But as you can see from the query in the query_db function I have the job_num hard coded. I need a way to get this when the first page is loaded. I have looked for a way to do this and nothing has worked. When I submit/add other files I can use the $_REQUEST['job_num'] to get it, but not when the page is loaded. I am not very familiar with OOP PHP so some of this is new to me. </p>