Long story short, I've been at this for quite a bit. I am teaching myself PHP, so please bear with any ignorance and I will happily clarify any and everything.
I'm using Blueimp's Jquery File Uploader and I'm having trouble having the uploader insert the uploaded files into the appropriate users' folder which I have set to be created automatically at registration. The JFU's native user directory ability does not work for me because all uploads are placed into the same session folder, a string of seemingly miscellaneous alphanumeric characters which I'm assuming is being read as the randomized session ID. So what I am trying to do is change the session to read as the logged-in username, and use that as its ID. I've scoured the internet and found various resources, but nothing has yet worked for me. Everything gets uploaded to the parent /uploads/ folder, but not the username-specific subfolders.
Previous post:
PHP Jquery File Upload // Username/Session Directories
(Some) Sources:
-How to get/set session_id() or should it be generated automatically?
-Jquery File Upload change session id
Using the advice given on my previous post, I still encounter the "Error SyntaxError: Unexpected token <" error, which I'm assuming means that the $username variable is failing to be defined/passed through.
The current login/session process is set at login, persists through pages, and exists as $loggedInUser->username (prints logged-in username on pages when called) and the session is read as $_SESSION['user_name']. I have tried applying every mix and match I can think of to the various sources I have found, and nothing seems to read the variable and insert the files into the appropriate user folders. Is there a way to tell the script to either read the session or read from database as the username, then upload into that username's folder?
My current code is as follows:
index.php
error_reporting(E_ALL | E_STRICT);
require('UploadHandler.php');
$upload_handler = new UploadHandler($username);
UploadHandler.php
function __construct($username, $options = null, $initialize = true, $error_messages = null) {
$this->response = array();
$this->options = array(
'script_url' => $this->get_full_url().'/'.basename($this->get_server_var('SCRIPT_NAME')),
'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'/../../uploads/'.$username.'/',
'upload_url' => $this->get_full_url().'/../../uploads/'.$username.'/',
'user_dirs' => false,
'mkdir_mode' => 0755,
'param_name' => 'files',
Thanks in advance for any and all help.