CodeIgniter uploads directory

2019-08-30 02:02发布

问题:

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?

回答1:

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])