Open_basedir restriction oddness

大憨熊 提交于 2019-12-11 07:15:55

问题


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


回答1:


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




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/7586616/open-basedir-restriction-oddness

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!