感谢Josegonzalez / Upload,我尝试在我的cakephp应用程序上传文件。而且我有以下错误。 在本地一切正常,但不在我的服务器。 顺便说一句,使用wordpress或简单的PHP表单上传文件可以在我的服务器上运行。 我必须指定
upload_tmp_dir = /tmp
使其适用于我的php.ini中的Wordpress。我也试过
open_basedir = /tmp
但它仍然不适用于cakephp。
Fatal error: [InvalidArgumentException] Invalid stream reference provided #0 /home/rom1/public_html/cakephp/vendor/zendframework/zend-diactoros/src/Stream.php(58): Zend\Diactoros\Stream->setStream('/tmp/phpKu6O1j', 'r') #1 /home/rom1/public_html/cakephp/vendor/zendframework/zend-diactoros/src/UploadedFile.php(164): Zend\Diactoros\Stream->__construct('/tmp/phpKu6O1j') #2 /home/rom1/public_html/cakephp/vendor/cakephp/cakephp/src/Http/ServerRequest.php(460): Zend\Diactoros\UploadedFile->getStream() #3 /home/rom1/public_html/cakephp/vendor/cakephp/cakephp/src/Http/ServerRequest.php(361): Cake\Http\ServerRequest->_processFiles(Array, Array) #4 /home/rom1/public_html/cakephp/vendor/cakephp/cakephp/src/Http/ServerRequest.php(300): Cake\Http\ServerRequest->_setConfig(Array) #5 /home/rom1/public_html/cakephp/vendor/cakephp/cakephp/src/Http/ServerRequestFactory.php(56): Cake\Http\ServerRequest->__construct(Array) #6 /home/rom1/public_html/cakephp/vendor/cakephp/c in /home/rom1/public_html/cakephp/vendor/cakephp/cakephp/src/Error/ErrorHandler.php on line 180
Warning: file_exists(): open_basedir restriction in effect. File(/home/rom1/public_html/cakephp/logs/error.log) is not within the allowed path(s): (..) in /home/rom1/public_html/cakephp/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 188
Warning: file_put_contents(): open_basedir restriction in effect. File(/home/rom1/public_html/cakephp/logs/error.log) is not within the allowed path(s): (..) in /home/rom1/public_html/cakephp/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 133
Warning: file_put_contents(/home/rom1/public_html/cakephp/logs/error.log): failed to open stream: Operation not permitted in /home/rom1/public_html/cakephp/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 133
Fatal error: [InvalidArgumentException] Invalid stream reference provided #0 /home/rom1/public_html/cakephp/vendor/zendframework/zend-diactoros/src/Stream.php(58): Zend\Diactoros\Stream->setStream('/tmp/phpKu6O1j', 'r') #1 /home/rom1/public_html/cakephp/vendor/zendframework/zend-diactoros/src/UploadedFile.php(164): Zend\Diactoros\Stream->__construct('/tmp/phpKu6O1j') #2 /home/rom1/public_html/cakephp/vendor/cakephp/cakephp/src/Http/ServerRequest.php(460): Zend\Diactoros\UploadedFile->getStream() #3 /home/rom1/public_html/cakephp/vendor/cakephp/cakephp/src/Http/ServerRequest.php(361): Cake\Http\ServerRequest->_processFiles(Array, Array) #4 /home/rom1/public_html/cakephp/vendor/cakephp/cakephp/src/Http/ServerRequest.php(300): Cake\Http\ServerRequest->_setConfig(Array) #5 /home/rom1/public_html/cakephp/vendor/cakephp/cakephp/src/Http/ServerRequestFactory.php(56): Cake\Http\ServerRequest->__construct(Array) #6 /home/rom1/public_html/cakephp/vendor/cakephp/c in /home/rom1/public_html/cakephp/vendor/cakephp/cakephp/src/Error/ErrorHandler.php on line 180
答案 0 :(得分:0)
我终于明白问题不在我的php.ini中。
当我使用userdir时,我不得不去/etc/apache2/mods-available/userdir.conf
并改变
php_admin_value open_basedir ".."
要
php_admin_value open_basedir ..:/tmp
但是我无法理解它为什么使用Wordpress而不是CakePHP ......