gpt4 book ai didi

php - 在 Codeigniter 中上传文件问题

转载 作者:搜寻专家 更新时间:2023-10-31 21:42:52 25 4
gpt4 key购买 nike

这是我在 codeigniter 应用程序中的 uploadinfg 文件代码

function upload_logo(){
$ex=$_FILES['uploadfile']['name'];
$epld=explode('.',$ex);
$filename=date("mdyHis").".".$epld[1];
$userfile_size=$_FILES['uploadfile']['size'];
$imggtype=$_FILES['uploadfile']['type'];
if(move_uploaded_file($_FILES['uploadfile']['tmp_name'],"./uploads/".$filename))
{
echo $filename;
}
}

这里 uploadfile 是文件字段的名称。我在根文件夹中有一个名称为 uploads 的文件夹。当我上传文件时出现错误。这在我们的服务器中工作,但在客户的服务器。

A PHP Error was encountered

Severity: Warning

Message: move_uploaded_file(./uploads/112911224341.docx) [function.move-uploaded-file]: failed to open stream: Permission denied

Filename: controllers/pms.php

Line Number: 156
A PHP Error was encountered

Severity: Warning

Message: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpvhzCkw' to './uploads/112911224341.docx'

Filename: controllers/pms.php

Line Number: 156

我该如何解决这个问题?

最佳答案

错误消息指出这是权限问题。确保您对上传文件夹设置了正确的权限。 From the documentation :

You'll need a destination folder for your uploaded images. Create a folder at the root of your CodeIgniter installation called uploads and set its file permissions to 777.

关于php - 在 Codeigniter 中上传文件问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8321275/

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