简体   繁体   English

move_uploaded_file无法打开流和权限被拒绝错误

[英]move_uploaded_file failed to open stream and Permission denied error

i'm trying to upload a file but i'm getting this following errors in my browser: 我正在尝试上传文件,但我在浏览器中遇到以下错误:

Warning  move_uploaded_file(public/upload/udesignwptheme138.zip) [function.move-uploaded-file]: failed to open stream: Permission denied in <b>/home/monivbr/public_html/classes/system/Util.php on line 1803

Warning:  move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpJtBlbi' to 'public/upload/udesignwptheme138.zip' in /home/monivbr/public_html/classes/system/Util.php on line 1803

this is my php class that make uploads to my server: 这是我上传到我的服务器的php类:

            foreach ($files as $file)
            if($file['tmp_name'] != "" && $file['error'] != 4){

                if($file['size'] < 10000000000){
                    $nome_antigo = $file["name"];
                    $novo_nome = strtolower(preg_replace("/[^a-zA-Z0-9_.]/", "", strtr($nome_antigo, "áàãâéêíóôõúüçÁÀÃÂÉÊÍÓÔÕÚÜÇ ", "aaaaeeiooouucAAAAEEIOOOUUC_")));


                    $query = $conexao->prepare('SELECT MAX(id) AS maxId FROM tbArquivo');
                    $query->execute();
                    $arquivo = $query->fetchObject();   

                    $caminhoArquivo = 'public/upload/';
                    $nomeArquivo = substr($novo_nome, 0, strripos($novo_nome, '.')).$arquivo->maxId;
                    if($idTipoArquivo == '6'){ //6 = arquivos xml de tradução
                        $caminhoArquivo  = 'public/traducao/';
                        $nomeArquivo = substr($novo_nome, 0, strripos($novo_nome, '.'));
                    }

                    $extensao = substr($novo_nome, strripos($novo_nome, '.'));

This line below is where is located the error: 下面的这一行是错误的位置:

move_uploaded_file($file["tmp_name"],$caminhoArquivo.$nomeArquivo.$extensao);




                    $query = $conexao->prepare("INSERT INTO tbArquivo
                                                (idTipoArquivo, idComplementar, idComplementar2, nomeArquivo, caminhoArquivo, tamanhoArquivo, extencaoArquivo, excluido)
                                                VALUES
                                                (:idTipoArquivo, :idComplementar, :idComplementar2, :nomeArquivo, :caminhoArquivo, :tamanhoArquivo, :extencaoArquivo, 0)");
                    $query->bindParam(":idTipoArquivo", $idTipoArquivo);
                    $query->bindParam(":idComplementar", $idComplementar);
                    $query->bindParam(":idComplementar2", $idComplementar2);
                    $query->bindParam(":nomeArquivo", $nomeArquivo);                
                    $query->bindParam(":caminhoArquivo", $caminhoArquivo);
                    $query->bindParam(":tamanhoArquivo", $file['size']);
                    $query->bindParam(":extencaoArquivo", $extensao);

                    $query->execute();

                }
            }   

this is my .htaccess file: 这是我的.htaccess文件:

php_value upload_max_filesize 30M
php_value post_max_size 30M
php_value max_input_time 6000000
php_value max_execution_time 6000000
php_value memory_limit 35M

this is the var_dump of the variables: 这是变量的var_dump:

var_dump($extensao);
var_dump($file["tmp_name"]);
var_dump($caminhoArquivo);
var_dump($nomeArquivo);

string(4) ".zip" string(14) "/tmp/phpKUpN24" string(14) "public/upload/" string(17) "udesignwptheme139" 

someone knows what culd be wrong ? 有人知道什么是错的?

Maybe you can consider changing the upload folder chmod 755 or 777 也许您可以考虑更改上传文件夹chmod 755或777

chmod 777 folder_path 

By this we are setting read. 通过这个我们设置阅读。 write and execute privilege for owner, group as well as others. 为所有者,组以及其他人编写和执行权限。

Its because of the you dont have the sufficient permission on the Folder. 因为你没有对文件夹的足够权限。 Change this permission to read and write. 更改此权限以进行读写。 That's all ! 就这样 !

不要更改文件夹路径

chmod -R 777 /home/monivbr/public_html/classes/system/Util.php

暂无
暂无

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

相关问题 move_uploaded_file 无法打开 stream:权限被拒绝 - Mac - move_uploaded_file failed to open stream: Permission denied - Mac move_uploaded_file 无法打开流:权限被拒绝 Mac - move_uploaded_file failed to open stream: Permission denied Mac move_uploaded_file给出:无法打开流:权限被拒绝 - move_uploaded_file gives: failed to open stream: Permission denied php 文件上传错误警告 move_uploaded_file 无法打开 stream 权限被拒绝 - php file upload error warning move_uploaded_file failed to open stream permission denied in Laravel中出现“ move_uploaded_file():无法打开流:权限被拒绝”错误 - Getting “move_uploaded_file(): failed to open stream: Permission denied” error in Laravel move_uploaded_file 给出“无法打开流:权限被拒绝”错误 - move_uploaded_file gives "failed to open stream: Permission denied" error move_uploaded_file(uploads /)[function.move-uploaded-file]:无法打开流:权限被拒绝 - move_uploaded_file(uploads/) [function.move-uploaded-file]: failed to open stream: Permission denied PHP警告:move_uploaded_file():无法移动/无法打开流:权限被拒绝 - PHP Warning: move_uploaded_file(): Unable to move/failed to open stream: Permission denied 上传文件警告:move_uploaded_file(../ view / pictureswhy.PNG):无法打开流:权限被拒绝 - Upload file Warning: move_uploaded_file(../view/pictureswhy.PNG): failed to open stream: Permission denied 警告:move_uploaded_file无法打开流:权限被拒绝的PHP文件 - Warning: move_uploaded_file failed to open stream: Permission denied PHP file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM