title: Connect Jquery FileUploader To My MySQL Database
body: <p>I'm trying to connect the blueimp jquery fileuploader on the postform of my site to mySQL database when files are being uploaded for post to the clients on my site's profile. I followed the instructions on several stackflow threads as well as used blueimp's github sql database integration instructions.</p>
  
  <p>I get the files to upload to the designated file path on my GoDaddy server and the file shows up on the list, but the file properties don't store in the database files table. If I submit the post everything stores in my database except for details for the file(s) uploaded with the post.</p>
  
  <p>My current code:
  (index.php file from fileuploader which is located in default server/php path)
  <div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  $options = array(
      'delete_type' =&gt; 'POST',
      'db_host' =&gt; 'localhost',
      'db_user' =&gt; 'my database user',
      'db_pass' =&gt; 'my database password',
      'db_name' =&gt; 'my database name',
      'db_table' =&gt; 'files'
  );
  error_reporting(E_ALL | E_STRICT);
  require('UploadHandler.php');
  class CustomUploadHandler extends UploadHandler {
      protected function initialize() {
          $this-&gt;db = new mysqli(
              $this-&gt;options['db_host'],
              $this-&gt;options['db_user'],
              $this-&gt;options['db_pass'],
              $this-&gt;options['db_name']
          );
          parent::initialize();
          $this-&gt;db-&gt;close();
      }
      protected function handle_form_data($file, $index) {
          $file-&gt;title = @$_REQUEST['title'][$index];
          $file-&gt;description = @$_REQUEST['description'][$index];
      }
      protected function handle_file_upload($uploaded_file, $name, $size, $type, $error,
              $index = null, $content_range = null) {
          $file = parent::handle_file_upload(
              $uploaded_file, $name, $size, $type, $error, $index, $content_range
          );
          if (empty($file-&gt;error)) {
              $sql = 'INSERT INTO `'.$this-&gt;options['db_table']
                  .'` (`name`, `size`, `type`, `title`, `description`)'
                  .' VALUES (?, ?, ?, ?, ?)';
              $query = $this-&gt;db-&gt;prepare($sql);
              $query-&gt;bind_param(
                  'sisss',
                  $file-&gt;name,
                  $file-&gt;size,
                  $file-&gt;type,
                  $file-&gt;title,
                  $file-&gt;description
              );
              $query-&gt;execute();
              $file-&gt;id = $this-&gt;db-&gt;insert_id;
          }
          return $file;
      }
      protected function set_additional_file_properties($file) {
          parent::set_additional_file_properties($file);
          if ($_SERVER['REQUEST_METHOD'] === 'GET') {
              $sql = 'SELECT `id`, `type`, `title`, `description` FROM `'
                  .$this-&gt;options['db_table'].'` WHERE `name`=?';
              $query = $this-&gt;db-&gt;prepare($sql);
              $query-&gt;bind_param('s', $file-&gt;name);
              $query-&gt;execute();
              $query-&gt;bind_result(
                  $id,
                  $type,
                  $title,
                  $description
              );
              while ($query-&gt;fetch()) {
                  $file-&gt;id = $id;
                  $file-&gt;type = $type;
                  $file-&gt;title = $title;
                  $file-&gt;description = $description;
              }
          }
      }
      public function delete($print_response = true) {
          $response = parent::delete(false);
          foreach ($response as $name =&gt; $deleted) {
              if ($deleted) {
                  $sql = 'DELETE FROM `'
                      .$this-&gt;options['db_table'].'` WHERE `name`=?';
                  $query = $this-&gt;db-&gt;prepare($sql);
                  $query-&gt;bind_param('s', $name);
                  $query-&gt;execute();
              }
          } 
          return $this-&gt;generate_response($response, $print_response);
      }
  
  }
  $upload_handler = new UploadHandler();</code></pre>
  </div>
  </div>
  </p>
  
  <p>(uploadhandler.php file from uploader. I changed the server port as suggested by GoDaddy)
  <div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code> protected function get_full_url() {
          $https = !empty($_SERVER['HTTPS']) &amp;&amp; strcasecmp($_SERVER['HTTPS'], 'on') === 0 ||
              !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) &amp;&amp;
                  strcasecmp($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') === 0;
          return
              ($https ? 'https://' : 'http://').
              (!empty($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'].'@' : '').
              (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME'].
              ($https &amp;&amp; $_SERVER['SERVER_PORT'] === 443 ||
              $_SERVER['SERVER_PORT'] === 22 ? '' : ':'.$_SERVER['SERVER_PORT']))).
              substr($_SERVER['SCRIPT_NAME'],0, strrpos($_SERVER['SCRIPT_NAME'], '/'));
      }</code></pre>
  </div>
  </div>
  </p>
  
  <p>(main.js file from uploader I changed url from server/php to server/php/index.php as I saw in a thread, and  hostname to hosting of my site to which I also tried the IP for my server hosting. 
  <div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>/* global $, window */
  $(function () {
      'use strict';
      // Initialize the jQuery File Upload widget:
      $('#fileupload').fileupload({
          url: 'server/php/index.php'
          }).on('fileuploadsubmit', function (e, data) {
          data.formData = data.context.find(':input').serializeArray();
      });
      // Enable iframe cross-domain access via redirect option:
      $('#fileupload').fileupload(
          'option',
          'redirect',
          window.location.href.replace(
              /\/[^\/]*$/,
              '/cors/result.html?%s'
          )
      );
      if (window.location.hostname === 'wmlmusicguide.com') {
          // Demo settings:
          $('#fileupload').fileupload('option', {
              url: '//wmlmusicguide.com/admin/master_admin/server/php/index.php',
              // Enable image resizing, except for Android and Opera,
              // which actually support image resizing, but fail to
              // send Blob objects via XHR requests:
              disableImageResize: /Android(?!.*Chrome)|Opera/
                  .test(window.navigator.userAgent),
              maxFileSize: 999000,
              acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i
          });
          // Upload server status check for browsers with CORS support:
          if ($.support.cors) {
              $.ajax({
                  url: '//wmlmusicguide.com/admin/master_admin/server/php/index.php',
                  type: 'HEAD'
              }).fail(function () {
                  $('&lt;div class="alert alert-danger"/&gt;')
                      .text('Upload server currently unavailable - ' +
                              new Date())
                      .appendTo('#fileupload');
              });
          }
      } else {
          // Load existing files:
          $('#fileupload').addClass('fileupload-processing');
          $.ajax({
              // Uncomment the following to send cross-domain cookies:
              //xhrFields: {withCredentials: true},
              url: $('#fileupload').fileupload('option', 'url'),
              dataType: 'json',
              context: $('#fileupload')[0]
          }).always(function () {
              $(this).removeClass('fileupload-processing');
          }).done(function (result) {
              $(this).fileupload('option', 'done')
                  .call(this, $.Event('done'), {result: result});
          });
      }
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>(Also tried in combination from another thread and assistance from a developer)
  <div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>/* global $, window */
  /*jslint unparam: true, regexp: true */
  /*global window, $ */
  $(function () {
      'use strict';
      // Initialize the jQuery File Upload widget:
      $('#fileupload').fileupload({
          // Uncomment the following to send cross-domain cookies:
          //xhrFields: {withCredentials: true},
          url: 'server/php/index.php'
      });
      // Enable iframe cross-domain access via redirect option:
      $('#fileupload').fileupload(
          'option',
          'redirect',
          window.location.href.replace(
              /\/[^\/]*$/,
              '/cors/result.html?%s'
          )
      );     
   $('#fileupload').fileupload({
    url: 'server/php/index.php'
    }).on('fileuploadsubmit', function (e, data) {
    data.formData = data.context.find(':input').serializeArray();
   });     
      // Change this to the location of your server-side upload handler:
      var url = window.location.hostname === 'GoDaddy server IP' ?                    '//wmlmusicguide.com/admin/master_admin/server/php/index.php' : '../../server/php/',
          uploadButton = $('&lt;button/&gt;')
              .addClass('btn btn-primary')
              .prop('disabled', true)
              .text('Processing...')
              .on('click', function () {
                  var $this = $(this),
                      data = $this.data();
                  $this
                      .off('click')
                      .text('Abort')
                      .on('click', function () {
                          $this.remove();
                          data.abort();
                      });
                  data.submit().always(function () {
                      $this.remove();
                  });
              });
      $('#fileupload').fileupload({
          url: url,
          dataType: 'json',
          autoUpload: false,
          acceptFileTypes: /(\.|\/)(gif|jpe?g|png|mp3|ogg|mp4)$/i,  
          maxFileSize: 26214400,
          // Enable image resizing, except for Android and Opera,
          // which actually support image resizing, but fail to
          // send Blob objects via XHR requests:
          disableImageResize: /Android(?!.*Chrome)|Opera/
              .test(window.navigator.userAgent),
          previewMaxWidth: 100,
          previewMaxHeight: 100,
          previewCrop: true
      }).on('fileuploadadd', function (e, data) {  
          data.context = $('&lt;div/&gt;').appendTo('#files');
          $.each(data.files, function (index, file) {
              var node = $('&lt;p/&gt;')
                      .append($('&lt;span/&gt;').text(file.name));
              if (!index) {
                  node
                      .append('&lt;br&gt;')
                      .append(uploadButton.clone(true).data(data));
              }
              node.appendTo(data.context);
          });
      }).on('fileuploadprocessalways', function (e, data) {
          var index = data.index,
              file = data.files[index],
              node = $(data.context.children()[index]);
          if (file.preview) {
              node
                  .prepend('&lt;br&gt;')
                  .prepend(file.preview);
          }
          if (file.error) {
              node
                  .append('&lt;br&gt;')
                  .append($('&lt;span class="text-danger"/&gt;').text(file.error));
          }
          if (index + 1 === data.files.length) {
              data.context.find('button')
                  .text('Upload')
                  .prop('disabled', !!data.files.error);
          }
      }).on('fileuploadprogressall', function (e, data) {
          var progress = parseInt(data.loaded / data.total * 100, 10);
          $('#progress .progress-bar').css(
              'width',
              progress + '%'
          );
      }).on('fileuploaddone', function (e, data) {
          $.each(data.result.files, function (index, file) {
              if (file.url) {
                  var link = $('&lt;a&gt;')
                      .attr('target', '_blank')
                      .prop('href', file.url);
                  $(data.context.children()[index])
                      .wrap(link);
              } else if (file.error) {
                  var error = $('&lt;span class="text-danger"/&gt;').text(file.error);
                  $(data.context.children()[index])
                      .append('&lt;br&gt;')
                      .append(error);
              }
          });
      }).on('fileuploadfail', function (e, data) {
          $.each(data.files, function (index) {
              var error = $('&lt;span class="text-danger"/&gt;').text('File upload failed.');
              $(data.context.children()[index])
                  .append('&lt;br&gt;')
                  .append(error);
          });
      }).prop('disabled', !$.support.fileInput)
          .parent().addClass($.support.fileInput ? undefined : 'disabled');
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>(backend for my post page where the uploader is)
  <div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>...
  &lt;!-- The file upload form used as target for the file upload widget --&gt;
  &lt;form id="fileupload" action="//jquery-file-upload.appspot.com/" method="POST" enctype="multipart/form-data"&gt;
      &lt;!-- Redirect browsers with JavaScript disabled to the origin page --&gt;
      &lt;noscript&gt;&lt;input type="hidden" name="redirect" value="https://blueimp.github.io/jQuery-File-Upload/"&gt;&lt;/noscript&gt;
      &lt;!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload --&gt;
      &lt;div class="fileupload-buttonbar"&gt;
          &lt;div class="fileupload-buttons"&gt;
              &lt;!-- The fileinput-button span is used to style the file input field as button --&gt;
              &lt;span class="fileinput-button"&gt;
                  &lt;span&gt;Add files...&lt;/span&gt;
                  &lt;input type="file" name="files[]" multiple&gt;
              &lt;/span&gt;
              &lt;button type="submit" class="start"&gt;Start upload&lt;/button&gt;
              &lt;button type="reset" class="cancel"&gt;Cancel upload&lt;/button&gt;
              &lt;button type="button" class="delete"&gt;Delete&lt;/button&gt;
              &lt;input type="checkbox" class="toggle"&gt;
              &lt;!-- The global file processing state --&gt;
              &lt;span class="fileupload-process"&gt;&lt;/span&gt;
          &lt;/div&gt;
          &lt;!-- The global progress state --&gt;
          &lt;div class="fileupload-progress fade" style="display:none"&gt;
              &lt;!-- The global progress bar --&gt;
              &lt;div class="progress" role="progressbar" aria-valuemin="0" aria-valuemax="100"&gt;&lt;/div&gt;
              &lt;!-- The extended global progress state --&gt;
              &lt;div class="progress-extended"&gt;&amp;nbsp;&lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;!-- The table listing the files available for upload/download --&gt;
      &lt;table role="presentation"&gt;&lt;tbody class="files"&gt;&lt;/tbody&gt;&lt;/table&gt;
  &lt;/form&gt;
  &lt;br&gt;
  &lt;!-- The blueimp Gallery widget --&gt;
  &lt;div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls" data-filter=":even"&gt;
      &lt;div class="slides"&gt;&lt;/div&gt;
      &lt;h3 class="title"&gt;&lt;/h3&gt;
      &lt;a class="prev"&gt;‹&lt;/a&gt;
      &lt;a class="next"&gt;›&lt;/a&gt;
      &lt;a class="close"&gt;×&lt;/a&gt;
      &lt;a class="play-pause"&gt;&lt;/a&gt;
      &lt;ol class="indicator"&gt;&lt;/ol&gt;
  &lt;/div&gt;
   &lt;div class="clear"&gt;&amp;nbsp;&lt;/div&gt;
  &lt;table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table"&gt;
   &lt;tr&gt;
    &lt;th rowspan="3" class="sized"&gt;&lt;img src="images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /&gt;&lt;/th&gt;
    &lt;th class="topleft"&gt;&lt;/th&gt;
    &lt;td id="tbl-border-top"&gt;&amp;nbsp;&lt;/td&gt;
    &lt;th class="topright"&gt;&lt;/th&gt;
    &lt;th rowspan="3" class="sized"&gt;&lt;img src="images/shared/side_shadowright.jpg" width="20" height="300" alt="" /&gt;&lt;/th&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
    &lt;td id="tbl-border-left"&gt;&lt;/td&gt;
    &lt;td&gt;
    &lt;!--  start content-table-inner ...... START --&gt;
    &lt;div id="content-table-inner"&gt;
    
     &lt;!--  start table-content  --&gt;
     &lt;div id="table-content" style="border:0px solid red"&gt;  
         
      &lt;form id="postForm" action="postcontroller.php" method="post" enctype="multipart/form-data"&gt;     
       &lt;!-- start id-form --&gt;
       &lt;table border="0" width="100%" cellpadding="0" cellspacing="0"  id="id-form"&gt;
       &lt;tr&gt;
        &lt;th valign="top"&gt;Post Title:&lt;/th&gt;
        &lt;td&gt;&lt;input type="text" class="inp-form required" name="name" value="&lt;?php if(isset($data['row']['name'])) echo $data['row']['name']; ?&gt;" /&gt;&lt;/td&gt;
       &lt;/tr&gt;
       &lt;tr&gt;
        &lt;th valign="top"&gt;Description:&lt;/th&gt;
        &lt;td&gt;&lt;textarea class="form-textarea" cols="" rows="" name="details"&gt;&lt;?php if(isset($data['row']['details'])) echo $data['row']['details']; ?&gt;&lt;/textarea&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
       &lt;/tr&gt;
       &lt;tr&gt;
        &lt;th valign="top"&gt;URL:&lt;/th&gt;
        &lt;td&gt;&lt;input type="url" class="inp-form" name="postlink" value="&lt;?php if(isset($data['row']['post_link'])) echo $data['row']['post_link']; ?&gt;" /&gt;&lt;/td&gt;
       &lt;/tr&gt; 
       &lt;tr&gt;     
        &lt;th valign="top"&gt;Client:&lt;/th&gt;
        &lt;td&gt;
        &lt;?php 
         $host_name = "localhost";
         $database = "wmy database name";   
         $username = "my username";         
         $password = "my password";          
  
         //////// Do not Edit below /////////
         try {
          $dbo = new PDO('mysql:host='.$host_name.';dbname='.$database, $username, $password);
          } catch (PDOException $e) {
          print "Error!: " . $e-&gt;getMessage() . "&lt;br/&gt;";
         die();
         }
         // Select all artists (clients) and order by name //
         $sql="SELECT aname FROM tbl_music_artists ORDER BY aname";
         // multi-select dropdown - select which artists (clients) receive posts //
        ?&gt; 
         &lt;select name="userids[]" class="chosen-select" data-placeholder="Choose a Client..." style="width:350px;" multiple&gt;
        &lt;?php 
         foreach ($dbo-&gt;query($sql) as $row){
         echo "&lt;option value=$row[id]&gt;$row[aname]&lt;/option&gt;";
         }
        ?&gt;
         &lt;/select&gt;
        &lt;/td&gt;
       &lt;/tr&gt;
       &lt;tr&gt;
        &lt;th valign="top"&gt;Category:&lt;/th&gt;
        &lt;td&gt;
         &lt;select class="chosen-select" name="category"&gt;
          &lt;option value=""&gt;Select option&lt;/option&gt;
          &lt;option value="music" &lt;?php if(isset($data['row']['category']) &amp;&amp; $data['row']['category'] == 'music') echo "selected";  ?&gt;&gt;Music&lt;/option&gt;
          &lt;option value="video" &lt;?php if(isset($data['row']['category']) &amp;&amp; $data['row']['category'] == 'video') echo "selected";  ?&gt;&gt;Video&lt;/option&gt;
         &lt;/select&gt;
        &lt;/td&gt;
       &lt;/tr&gt;
       &lt;tr&gt;
        &lt;th valign="top"&gt;Status:&lt;/th&gt;
        &lt;td&gt;
         &lt;select class="chosen-select" name="status"&gt;
          &lt;option value="1" &lt;?php if(isset($data['row']['status']) &amp;&amp; $data['row']['status'] == '1') echo "selected";  ?&gt;&gt;Active&lt;/option&gt;
          &lt;option value="0" &lt;?php if(isset($data['row']['status']) &amp;&amp; $data['row']['status'] == '0') echo "selected";  ?&gt;&gt;Inactive&lt;/option&gt;
         &lt;/select&gt;
        &lt;/td&gt;
       &lt;/tr&gt;
       &lt;tr&gt;
        &lt;td&gt;&amp;nbsp;&lt;/td&gt;
        &lt;td&gt;
         &lt;input type="submit" value="" class="form-submit" /&gt;
         &lt;input id="restform" class="form-reset"&gt;
         &lt;a href="post.php" class="form-cancel"&gt;Cancel&lt;/a&gt;
        &lt;/td&gt;
        &lt;td&gt;&amp;nbsp;&lt;/td&gt;
        &lt;td&gt;&amp;nbsp;&lt;/td&gt;
       &lt;/tr&gt;
       &lt;/table&gt;
       &lt;input type="hidden" name="form" value="&lt;?php echo $data['formStatus'] ?&gt;" /&gt;
       &lt;input type="hidden" name="id" id="id" value="&lt;?php echo $data['id'] ?&gt;" /&gt;
      &lt;/form&gt;
     &lt;/td&gt;
    &lt;/tr&gt;
   &lt;/table&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
   &lt;div class="clear"&gt;&amp;nbsp;&lt;/div&gt;
   
  &lt;!-- The template to display files available for upload --&gt;
  &lt;script id="template-upload" type="text/x-tmpl"&gt;
  {% for (var i=0, file; file=o.files[i]; i++) { %}
      &lt;tr class="template-upload fade"&gt;
          &lt;td&gt;
              &lt;span class="preview"&gt;&lt;/span&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;p class="name"&gt;{%=file.name%}&lt;/p&gt;
              &lt;strong class="error"&gt;&lt;/strong&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;p class="size"&gt;Processing...&lt;/p&gt;
              &lt;div class="progress"&gt;&lt;/div&gt;
          &lt;/td&gt;
          &lt;td&gt;
              {% if (!i &amp;&amp; !o.options.autoUpload) { %}
                  &lt;button class="start" disabled&gt;Start&lt;/button&gt;
              {% } %}
              {% if (!i) { %}
                  &lt;button class="cancel"&gt;Cancel&lt;/button&gt;
              {% } %}
          &lt;/td&gt;
      &lt;/tr&gt;
  {% } %}
  &lt;/script&gt;
  &lt;!-- The template to display files available for download --&gt;
  &lt;script id="template-download" type="text/x-tmpl"&gt;
  {% for (var i=0, file; file=o.files[i]; i++) { %}
      &lt;tr class="template-download fade"&gt;
          &lt;td&gt;
              &lt;span class="preview"&gt;
                  {% if (file.thumbnailUrl) { %}
                      &lt;a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" data-gallery&gt;&lt;img src="{%=file.thumbnailUrl%}"&gt;&lt;/a&gt;
                  {% } %}
              &lt;/span&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;p class="name"&gt;
                  &lt;a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}&gt;{%=file.name%}&lt;/a&gt;
              &lt;/p&gt;
              {% if (file.error) { %}
                  &lt;div&gt;&lt;span class="error"&gt;Error&lt;/span&gt; {%=file.error%}&lt;/div&gt;
              {% } %}
          &lt;/td&gt;
          &lt;td&gt;
              &lt;span class="size"&gt;{%=o.formatFileSize(file.size)%}&lt;/span&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;button class="delete" data-type="{%=file.deleteType%}" data-url="{%=file.deleteUrl%}"{% if (file.deleteWithCredentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}&gt;Delete&lt;/button&gt;
              &lt;input type="checkbox" name="delete" value="1" class="toggle"&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  {% } %}
  &lt;/script&gt;
  &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"&gt;&lt;/script&gt;
  &lt;!-- The Templates plugin is included to render the upload/download listings --&gt;
  &lt;script src="//blueimp.github.io/JavaScript-Templates/js/tmpl.min.js"&gt;&lt;/script&gt;
  &lt;!-- The Load Image plugin is included for the preview images and image resizing functionality --&gt;
  &lt;script src="//blueimp.github.io/JavaScript-Load-Image/js/load-image.all.min.js"&gt;&lt;/script&gt;
  &lt;!-- The Canvas to Blob plugin is included for image resizing functionality --&gt;
  &lt;script src="//blueimp.github.io/JavaScript-Canvas-to-Blob/js/canvas-to-blob.min.js"&gt;&lt;/script&gt;
  &lt;!-- blueimp Gallery script --&gt;
  &lt;script src="//blueimp.github.io/Gallery/js/jquery.blueimp-gallery.min.js"&gt;&lt;/script&gt;
  &lt;!-- The Iframe Transport is required for browsers without support for XHR file uploads --&gt;
  &lt;script src="../js/jquery.iframe-transport.js"&gt;&lt;/script&gt;
  &lt;!-- The basic File Upload plugin --&gt;
  &lt;script src="../js/jquery.fileupload.js"&gt;&lt;/script&gt;
  &lt;!-- The File Upload processing plugin --&gt;
  &lt;script src="../js/jquery.fileupload-process.js"&gt;&lt;/script&gt;
  &lt;!-- The File Upload image preview &amp; resize plugin --&gt;
  &lt;script src="../js/jquery.fileupload-image.js"&gt;&lt;/script&gt;
  &lt;!-- The File Upload audio preview plugin --&gt;
  &lt;script src="../js/jquery.fileupload-audio.js"&gt;&lt;/script&gt;
  &lt;!-- The File Upload video preview plugin --&gt;
  &lt;script src="../js/jquery.fileupload-video.js"&gt;&lt;/script&gt;
  &lt;!-- The File Upload validation plugin --&gt;
  &lt;script src="../js/jquery.fileupload-validate.js"&gt;&lt;/script&gt;
  &lt;!-- The File Upload user interface plugin --&gt;
  &lt;script src="../js/jquery.fileupload-ui.js"&gt;&lt;/script&gt;
  &lt;!-- The File Upload jQuery UI plugin --&gt;
  &lt;script src="../js/jquery.fileupload-jquery-ui.js"&gt;&lt;/script&gt;
  &lt;!-- The main application script --&gt;
  &lt;script src="../js/main.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  // Initialize the jQuery UI theme switcher:
  $('#theme-switcher').change(function () {
      var theme = $('#theme');
      theme.prop(
          'href',
          theme.prop('href').replace(
              /[\w\-]+\/jquery-ui.css/,
              $(this).val() + '/jquery-ui.css'
          )
      );
  });
  // Post Form Validate
   $(document).ready(function () {
    $('#postForm').validate({
     errorElement: "div",
     rules: {
         name: { required: true },
         details: { required: true },
         category: { required: true }
       }
    });
    $('#restform').click(function(){
              $('#postForm')[0].reset();
     });
   });
  // Chosen multi-select
   var config = {
   '.chosen-select' : {},
   '.chosen-select-deselect' : {allow_single_deselect:true},
   '.chosen-select-no-single' : {disable_search_threshold:10},
   '.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},
   '.chosen-select-width' : {width:"95%"}
   }
   for (var selector in config) {
   $(selector).chosen(config[selector]);
   } 
  &lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>(frontend connection to my post page)
  <div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php    
   include('includes/inc.php');
   include("includes/classes/class.post.php");
   include("includes/classes/class.artist.php");
   $post  = new Post();
   
   //new 
   $data['formStatus'] = 'new';
   $data['id'] = 0;
   $data['aid'] = 0;
   if($_SERVER['REQUEST_METHOD'] == 'GET'){
    $id  = isset($_GET['id']) ? $_GET['id'] : 0;
    $checkRow = $post-&gt;get_row($id);
    if(is_array($checkRow)){
     $data['formStatus'] = 'edit';
     $data['row'] = $checkRow;
     $data['id'] = $checkRow['id'];
     $data['post'] = checkImagexists('../../uploads/', 'post_' . $checkRow['id']);
    }
   }
   layout('post_form', $data);
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>(postcontroller file where I first tried to get files from the file uploader)
  <div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php    
   session_start();
   include("includes/functions.php");
   include("includes/classes/class.post.php");      
   if($_SERVER['REQUEST_METHOD'] == 'POST'){ 
   //Get newly uploaded files from /uploads/server/php
    $files = $_POST['files'];        
    if(!empty($files)){
     //Rename all files in the upload server php directory to post_id format
     //Move files to upload directory
     foreach ($files as $file){  
      if ($handle = opendir('../../uploads/server/php/')) {
       while (false !== ($fileName = readdir($handle))) {
        $newName = '../../uploads/' . 'post_' . $_POST['id'] . '_' . $file;
        $oldName = '../../uploads/client/files/' . $file;
        rename($oldName, $newName);
       }
      }
      closedir($handle);
     }
    }   
    
    $client_cat = isset($_POST['userids']) ? $_POST['userids'] : array(); 
    $user_id = $_SESSION['user_id'];      
    // Client post to own page
    $post = new post();
    $arrData = array();      
    $arrData['name'] = addslashes(ucwords($_POST['name']));
    $arrData['details'] = addslashes($_POST['details']);
    $arrData['post_link'] = $_POST['post_link'];  
    $arrData['status'] = addslashes($_POST['status']);
    $arrData['type'] = $_FILES['image']['type'];
    $arrData['category'] = addslashes($_POST['category']);       
    if(empty($_POST['id'])){
     $arrData['user_id'] = $user_id;
     $arrData['added_date'] = date('Y-m-d H:i:s'); 
     $insert = $post-&gt;add($arrData);
     if($insert){
      $client_prop = array_merge($client_cat, $files);
      $client-&gt;add_prop($client_prop, $insert, 'artist');
     }
    }  
   }
   else
   {
    echo "Invalid file";
   }
   header('Location: post.php?act=' . $_SESSION['insert_post']);
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><a href="http://i.stack.imgur.com/IYjIW.png" rel="nofollow">screenshot of index.php for the uploader where i tried to make the connection to my database as instructed</a>
  <a href="http://i.stack.imgur.com/cmmoI.jpg" rel="nofollow">screenshot of mysql post &amp; files table, the fields that were created as instructed</a></p>