在Codeigniter中上传文件问题 [英] Uploading File Issue In Codeigniter
问题描述
这是我在codeigniter应用程序中的uploadinfg文件代码
This is my uploadinfg files code in codeigniter application
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
是文件字段的名称。我有一个文件夹名称上传在根文件夹中。当我上传文件我得到错误。这是在我们的服务器,但不是在客户端的服务器工作。
Here uploadfile
is the name of the file field.And i have a folder with name uploads in root folder.When i uploading file i got errors.This is working in our server but not working in client's server.
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
我如何解决这个问题?
推荐答案
消息指出它是一个权限问题。确保您在uploads文件夹中设置了正确的权限。 从文档:
The error message states that it's a permissions issue. Ensure that you have the correct permissions set on the the uploads folder. From the documentation:
您需要为上传的图片设置目标文件夹。在您的CodeIgniter安装根目录下创建一个
文件夹,名为uploads,
将其文件权限设置为777.
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.
这篇关于在Codeigniter中上传文件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!