简体   繁体   English

上传文件CakePHP致命错误

[英]Upload file CakePHP Fatal Error

I try to upload a file on my cakephp app thanks to Josegonzalez/Upload. 多亏了Josegonzalez / Upload,我尝试将文件上传到我的cakephp应用程序上。 And I've got the following error. 而且我遇到了以下错误。 In local everything works, but not in my server. 在本地,一切正常,但在我的服务器中不起作用。 By the way, file upload with wordpress or with a simple PHP form works on my server. 顺便说一下,在我的服务器上可以使用wordpress或简单的PHP表单上传文件。 I had to specify 我必须指定

upload_tmp_dir = /tmp

to make it work for Wordpress in my php.ini. 使它适用于我的php.ini中的Wordpress。 I also tried 我也试过

open_basedir = /tmp

but it still does not work for cakephp. 但它仍然不适用于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

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

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

I finally understood that the problem was not in my php.ini. 我终于明白,问题不在我的php.ini中。

As I'm working with userdir, I had to go to /etc/apache2/mods-available/userdir.conf 在使用userdir时,我必须转到/etc/apache2/mods-available/userdir.conf

And change 并改变

php_admin_value open_basedir ".."

To

php_admin_value open_basedir ..:/tmp

But I can't get why it was working with Wordpress and not CakePHP… 但是我不知道为什么它可以用Wordpress而不用CakePHP。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM