move_uploaded_file fails randomly with open_basedir and upload_tmp_dir

From: Date: Mon, 27 Aug 2007 17:55:08 +0000
Subject: move_uploaded_file fails randomly with open_basedir and upload_tmp_dir
Groups: php.general 
Request: Send a blank email to php-general+get-261369@lists.php.net to get a copy of this message
Hi all, I'm having a weird problem on my web hosting provider's server. I'm using drupal with the image module and the image_pub module to upload a series of pictures using Gallery Remote. This software uploads pictures one after the other using a classic HTTP POST method. The upload always succeeds, but the problem I have is that move_uploaded_file() randomly fails. open_basedir is set to /home/ DOCUMENT_ROOT is /home/myuser upload_tmp_dir is set to ./tmp-php/, which exists is /home/myuser and has full 777 permission the script is called from the DOCUMENT_ROOT directory: /test.php which is in fact /home/myuser/test.php In the script, just before calling move_uploaded_file, I created a file in the current directory with debug values in it. It is indeed created in the DOCUMENT_ROOT directory. The errors I have are: First, 2 times: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. File(/var/tmp/phpNN2JDd) is not within the allowed path(s): (/home/) then: move_uploaded_file(/var/tmp/phpNN2JDd) [function.move-uploaded-file]: failed to open stream: Operation not permitted move_uploaded_file() [function.move-uploaded-file]: Unable to move '/var/tmp/phpNN2JDd' to 'files/tmp/res-2108703551.jpg' When it succeeds, the file is correctly uploaded in ./tmp-php. When it fails, it goes to /var/tmp although upload_tmp_dir is still set to "./tmp-php/". is_uploaded_file() returns true even when move_uploaded_file() fails. What seems really strange to me is that it fails *randomly*. It works for a couple of picture, then fails, then succeeds again, etc. My web hosting provider doesn't really seem to care about such problems, so if I can point out this is a PHP bug and ask them for an update, it would be great. Running PHP version 5.1.6 on FreeBSD 5.4-RELEASE-p13 Configure Command './configure' '--enable-fastcgi' '--prefix=/usr/local/php5' '--with-config-file=/usr/local/php5/lib/php.ini' '--with-config-file-path=/usr/local/php5/lib' '--enable-versioning' '--with-openssl' '--with-zlib' '--with-zlib-dir=/usr' '--enable-bcmath' '--with-bz2' '--enable-calendar' '--with-jpeg-dir=/usr/local' '--with-tiff-dir=/usr/local' '--with-curl=/usr/local' '--enable-exif' '--enable-ftp' '--with-gd=/usr/local' '--with-png-dir=/usr/local' '--with-xpm-dir=/usr/local' '--with-ttf' '--with-freetype-dir=/usr/local' '--with-t1lib' '--enable-gd-native-ttf' '--with-gdbm' '--with-gettext' '--with-imap-ssl' '--enable-mbstring' '--with-mcrypt' '--with-mhash' '--with-mysql=/usr/local' '--with-unixODBC' '--with-dom=/usr/local' '--with-dom-xslt=/usr/local' '--with-dom-exslt=/usr/local' '--with-mcal' '--with-xsl' '--enable-xslt' '--with-xslt-sablot' '--with-iconv-dir=/usr/local' '--enable-trans-sid' '--enable-memory-limit' '--enable-zend-multibyte' Server API CGI/FastCGI Apache/1.3.37 (Unix) mod_fastcgi/mod_fastcgi-SNAP-0404142202

« previous php.general (#261369) next »