title: PHP Jquery File Upload // Username/Session Directories
body: <p>I have been messing around with Blueimp's Jquery File Upload for a couple weeks on PHP and I am encountering some issues. I am teaching myself how to program in PHP so I am still getting acclimated to how things work, so apologies for any confusion and I will attempt to clarify as best I can. </p>
  
  <p>I need user uploads to be inserted into their specific username folders in the upload destination directory. I have followed the numerous writeups, answers and faqs for turning on said user directories (for this plugin) and at best, a folder is created for the session with a string of misc. characters, but all uploads regardless of the username go to the same folder, not the users' respective folder. Is it possible to tell the script to read and use the specific username/id/etc as a variable? I'm pretty sure it is, but currently I cannot find a clear-cut method. I have tried to keep my code as basic and similar to the released Blueimp versions for the sake of clarity. </p>
  
  <p>So, here goes.</p>
  
  <p>**Working:**User registers, info is inserted into database, a respective username folder is automatically created inside the upload directory and waits patiently to be filled with delicious files.</p>
  
  <p>**Not working:**Upload script is not reading the username/variable to be used as the target folder name. When executed, "Error SyntaxError: Unexpected token &lt;" is returned, and inserts the uploaded file into the parent "/uploads/" folder.</p>
  
  <p>index.php (inside the original server/php/ directory)</p>
  
  <pre><code>error_reporting(E_ALL | E_STRICT);
  require('UploadHandler.php');
  $upload_handler = new UploadHandler();
  </code></pre>
  
  <p>UploadHandler.php</p>
  
  <pre><code>function __construct($options = null, $initialize = true, $error_messages = null) {
      $this-&gt;response = array();
      $this-&gt;options = array(
          'script_url' =&gt; $this-&gt;get_full_url().'/'.basename($this-&gt;get_server_var('SCRIPT_NAME')),
          'upload_dir' =&gt; dirname($this-&gt;get_server_var('SCRIPT_FILENAME')).'/../../uploads/'.$username.'/',
          'upload_url' =&gt; $this-&gt;get_full_url().'/../../uploads/'.$username.'/',
          'user_dirs' =&gt; false,
          'mkdir_mode' =&gt; 0755,
          'param_name' =&gt; 'files',
  </code></pre>
  
  <p>My understanding is that the $username variable needs to be defined, but where and how is where I'm lost. I can have the page call and print the username, id, email, and pretty much anything else -on- the page, but the variable/token is not translating into the upload directory script. </p>
  
  <p>Thanks in advance for any input. </p>