gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:56:43 26 4
gpt4 key购买 nike

我正在尝试上传文件,但我的浏览器出现以下错误:

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

这是我的上传到我的服务器的 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, '.'));

下面这一行是错误所在:

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();

}
}

这是我的 .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

这是变量的 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"

有人知道什么可能是错的吗?

最佳答案

也许你可以考虑更改上传文件夹chmod 755或777

chmod 777 folder_path 

通过这个我们设置读取。所有者、组以及其他人的写入和执行权限。

关于php - move_uploaded_file 无法打开流和权限被拒绝错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20582507/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com