Codeigniter允许上传.php文件 [英] Codeigniter allow .php file uploads
问题描述
我使用的是内置于文件上传库中的codigniters,并且我希望允许上传php文件。
I am using codigniters built in file upload library, and I want to allow php files to be uploaded.
此功能仅对安全的管理员用户可用。登录等。
This facility is only available to admin users behind a secure login etc.
但是由于某些原因,我收到不允许您尝试上传的文件类型错误。
But for some reason, I am getting 'The filetype you are attempting to upload is not allowed' errors.
我在我的控制器中有这个:
I have this in my controller:
$config['allowed_types'] = 'pdf|doc|docx|php';
我在config / mimes.php中也有这行:
And I also have this line in config/mimes.php:
'php' => 'application/x-httpd-php',
如果我尝试上传图像,则此功能有效文件等,因此可以正常工作,只是不允许使用.php文件。
This actualy functionality works if i try to upload an image file etc, so it is working, just not allowing .php files.
有什么想法为什么不起作用?我错过了什么吗?
Any ideas why this doesnt work? Am i missing something?
推荐答案
想通了!
当我查看发布的数据时,MIME类型为Content-Type:text / php
When i looked at posted data, the mime type was Content-Type: text/php
但是mime.php中相应的mime类型为:
But the corresponding mime type in mime.php was:
'php' => 'application/x-httpd-php',
所以我将其更改为:
'php' => array('application/x-httpd-php', 'text/php'),
hallelujah !!
hallelujah!!
这篇关于Codeigniter允许上传.php文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!