Question

I have been having trouble using a file upload script on my server - came to the conclusion that this was because PHP was being run on Apache Module so reconfigured PHP to run as FastCGI.

Unfortunately now when I try to upload a file via uploadify I get the error

Warning: move_uploaded_file()[function.move-uploaded-file] open_base_dir restrictions in effect. File(/var/www/vhosts/domain.com/uploads/filename.txt) is not within the allowed path(s):(/var/www/vhosts/domain.com/httpdocs:/tmp) in .....

It then refers me to line 32 of my script which reads:

move_uploaded_file($tempFile,$targetFile);

$tempFile is as follows:

$tempFile = str_replace(" ","",$_FILES['Filedata']['tmp_name']);

I have tried altering my vhost.conf file in numerous ways bit without success - it currently stands as

<Directory /var/www/vhosts/domain.com/httpdocs>
    <IfModule sapi_apache2.c>
            php_admin_flag engine off
            php_admin_flag safe_mode on
            php_admin_value open_basedir none
    <IfModule mod_php5.c>
            php_admin_flag engine on
            php_admin_flag safe_mode off
            php_admin_value open_basedir none
   </IfModule>
</Directory>

I seem to be going round in circles - it seems that the tmp directory is not being found

Was it helpful?

Solution

If it's your server and you can actually mess around with configuration, you can turn off the open_basedir in your php.ini, reload PHP and try if it works. safe_mode should be turned off in PHP by default as this option causes only problems.

Or you can try following:

<Directory /var/www/vhosts/domain.com/httpdocs>
    php_admin_value open_basedir "/var/www/vhosts/domain.com/httpdocs/:/tmp/:/var/www/vhosts/domain.com/uploads/"
</Directory>

Same can apply for the php.ini if you decide to set the config there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top