CodeIgniter上传目录
我正在努力实现:
我正在使用 CodeIgniter。
我正在尝试访问http://localhost/mywebsite/uploads/
。该目录存在,并且通过 第 3 方上传脚本,我可以成功写入该目录。但是,当直接访问 URL(或在 src 属性中引用其文件)时,会出现 404 错误。
我认为最好的方法是:
确保我的 $config['base_url']
设置为 http://localhost/mywebsite/< /代码>。
(由于未知原因,我可以访问 /mywebsite/js/
,但不能访问 /mywebsite/uploads/
。)
我 阅读文档,它说:
在 CodeIgniter 安装的根目录下创建一个名为 上传并将其文件权限设置为777。
这可以上传到,但不能从中访问!
我做到了,我希望看到:
目录列表或权限被拒绝的页面。我什至尝试直接访问文件,例如http://localhost/mywebsite/uploads/myfile.jpg。
相反,我看到:
404页面未找到
找不到您请求的页面。
我做错了什么?
I'm trying to achieve:
I am using CodeIgniter.
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.
I thought the best way to do this was to:
Make sure my $config['base_url']
was set to http://localhost/mywebsite/
.
(For an unknown reason, I can access /mywebsite/js/
but not /mywebsite/uploads/
.)
I read the documentation and it said to:
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!
I did it, I expected to see:
Either a directory listing or permission denied page. I even tried going straight to a file, like http://localhost/mywebsite/uploads/myfile.jpg
.
Instead, I saw:
404 Page Not Found
The page you requested was not found.
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请检查您的 .htaccess 文件,
不应该有任何规则来限制对上传文件夹的访问。
(“上传”不应出现在此规则中:RewriteRule ^(css|js|ckeditor) - [L])
Please check your .htaccess file,
there shouldn't be any rule to restrict the access to the uploads folder.
("uploads" should not appear within this rule: RewriteRule ^(css|js|ckeditor) - [L])