CodeIgniter上传目录

发布于 2025-01-01 02:35:47 字数 990 浏览 1 评论 0原文

我正在努力实现:

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

征棹 2025-01-08 02:35:47

请检查您的 .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])

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文