CodeIgniter上传目录 [英] CodeIgniter uploads directory

查看:103
本文介绍了CodeIgniter上传目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想尝试实现

我正在使用CodeIgniter。

I am using CodeIgniter.

我试图访问 http:// localhost / mywebsite / uploads / 。该目录已存在,并通过第三方上传脚本,我可以成功地写入该目录。但是,当直接访问URL(或引用它的src属性中的文件)时,它给我一个404错误。

I am trying to access http://localhost/mywebsite/uploads/. The directory exists, and via a 3rd party upload script, I can successfully write to that directory. However, when going straight to the URL (or referencing its files in an src attribute), it gives me a 404 error.

我认为最好的方法这样做是为了:

确保我的 $ config ['base_url'] http:// localhost / mywebsite /

(由于未知原因,我可以访问 / mywebsite / js / ,但不包括 / mywebsite / uploads / 。)

(For an unknown reason, I can access /mywebsite/js/ but not /mywebsite/uploads/.)

阅读文档,它说:

I read the documentation and it said to:


在您的CodeIgniter安装根目录下创建一个名为
的文件夹,并将其文件权限设置为777.

Create a folder at the root of your CodeIgniter installation called uploads and set its file permissions to 777.

可以上传到,但无法访问!

That works to upload to, but it doesn't work to access from!

我这样做了,我希望看到:

目录列表或权限被拒绝页面。我甚至尝试直接去一个文件,如 http://localhost/mywebsite/uploads/myfile.jpg

Either a directory listing or permission denied page. I even tried going straight to a file, like http://localhost/mywebsite/uploads/myfile.jpg.

我看到了:


404页面未找到

404 Page Not Found

找不到您要求的专页。

我做错了什么?

推荐答案

请检查您的.htaccess文件,
不应有任何规则限制对uploads文件夹的访问。

Please check your .htaccess file, there shouldn't be any rule to restrict the access to the uploads folder.

(uploads不应出现在此规则中:RewriteRule ^(css | js | ckeditor) - [L])

("uploads" should not appear within this rule: RewriteRule ^(css|js|ckeditor) - [L])

这篇关于CodeIgniter上传目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆