Upload file type

2019-09-08 05:38发布

问题:

I've created an upload file and it won't save in database. I created the controller and the view like codeigniter tutorial says.

I put in the config the allowed_types.

 $config['allowed_types'] = 'gif|jpg|png|jpeg';

and it continues to show me this:

 The filetype you are attempting to upload is not allowed.

What should I do?

回答1:

This is an issue that occurs in CodeIgniter 2.1.0 and PHP v5.2.x. If you downgrade back to CodeIgniter 2.0.3, the upload problem should go away.



回答2:

Replace your system/libraries/Upload.php with this one:

https://raw.github.com/narfbg/CodeIgniter/320ddaa3d01c9d8ee6832fa25f9273e2588c63dd/system/libraries/Upload.php

This is a new version of the Upload class that's currently waiting to be merged - it should fix any issue that you might have with file detection on upload.