Take the 2-minute tour ×

I would like to change the location that a files uploads to by adding a PHP variable to the path name but I am unable to get it to work but I'm pretty sure it's a syntax error.

This doesn't work:

$this->options = array(
     'script_url' => $this->get_full_url().'/',
     'upload_dir' => dirname($_SERVER['SCRIPT_FILENAME']).'/'.$user.'/',
     'upload_url' => $this->get_full_url().'/'.$user.'/',
     'param_name' => 'files'

This does:

$this->options = array(
     'upload_dir' => dirname($_SERVER['SCRIPT_FILENAME']).'/bob/',
     'upload_url' => $this->get_full_url().'/bob/',
     'param_name' => 'files'

I realize that this is not the full code, but I wondered whether there is a simple syntax error I am missing here.

share|improve this question
Have you checked the value of $user? What is it? –  BenM Oct 8 '12 at 19:47
Nothing discernible here, assuming both statements close with a );... what comes above this code? That's probably where the syntax problem lies, but the parser doesn't find it until later on. –  Set Sail Media Oct 8 '12 at 19:48
Hi the value of $user is bob '$user = 'bob';' –  user1729812 Oct 8 '12 at 19:49
what if you change user to '/bob/'? –  Jake Rowsell Oct 8 '12 at 19:49
First and foremost always activate error displaying. error_reporting(E_ALL); ini_set('display_errors', TRUE); because obviously there is some kind of error there that is not show to you and you need to read the error message and start searching based on that. –  Mihai Stancu Oct 8 '12 at 19:53

1 Answer 1

You don't appear to have defined $user anywhere. Even if you have, the code you gave seems to be part of a class declaration so you need to make sure $user is defined in the current scope (global $user if needed, or as a last resort try $GLOBALS['user']).

share|improve this answer
If this is the case, I recommend reading the manual on variable scope. –  cmbuckley Oct 8 '12 at 19:55

Your Answer


