Open_basedir restriction oddness

2019-08-04 19:23发布

I'm having a problem with move_uploaded_file in PHP, with the returned error message telling me that the open_basedir restriction is in place (which I've set) and that on the path I'm attempting to write to is not within the allowed paths, but it is (and is clearly displayed on the error message).

Has anyone come across this before?

Edit:

Sorry, the error message might help!:

Unhandled Error (/var/www/vhosts/(myhost)/libs/imanager.php, 226): 2, '...move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. File(/var/www/vhosts/(myhost)/httpdocs/tributes/images/precrop/1317227884228.jpg) is not within the allowed path(s): (/var/www/vhosts/(myhost)/httpdocs/tributes/images/precrop/:/tmp)...'

3条回答
Deceive 欺骗
2楼-- · 2019-08-04 19:56

Not come across this before. You can only use move_uploaded_file if the file you are trying to move was uploaded using PHP. Try removing the trailing '/' from your precrop directory in the configuration.

There's some extra open_basedir information here: http://www.bigsoft.co.uk/blog/index.php/2007/12/30/fixing-php-s-require-open_basedir-restri

查看更多
小情绪 Triste *
3楼-- · 2019-08-04 19:59

There is PHP bug ("Regression (5.3.3-5.3.4) in open_basedir with a trailing forward slash"), that is triggered when open_basedir have trailing slash. As workaround remove trailing slash from path in open_basedir. This bug should be fixed in recent versions of PHP.

查看更多
smile是对你的礼貌
4楼-- · 2019-08-04 20:01

Note that open_basedir will also fail if you have symlinks along the path. From http://php.net/open_basedir:

All symbolic links are resolved, so it's not possible to avoid this restriction with a symlink.

Please check if /var/www/vhosts/(yourhost)/httpdocs/tributes/images/precrop/ is a real directory path, not symlinked one.

查看更多
登录 后发表回答