1

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(
     'script_url' => $this->get_full_url().'/',
     '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.

10
  • Have you checked the value of $user? What is it? Commented Oct 8, 2012 at 19:47
  • 1
    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. Commented Oct 8, 2012 at 19:48
  • Hi the value of $user is bob '$user = 'bob';' Commented Oct 8, 2012 at 19:49
  • what if you change user to '/bob/'? Commented Oct 8, 2012 at 19:49
  • 1
    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. Commented Oct 8, 2012 at 19:53

1 Answer 1

2

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']).

Sign up to request clarification or add additional context in comments.

1 Comment

If this is the case, I recommend reading the manual on variable scope.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.