apache - codeigniter htaccess php instructions not working

253

In my php.ini I have disabled file upload globally:

file_uploads = Off

And i tried to enable file upload for my codeigniter site only. So i added to the .htaccess file the following:

php_flag file_uploads 1

And I made sure thatAllowOverride is setup as follow in theapache config file:

<Directory /var/www/my_codeigniter_app/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

However file upload is not working. It only works, when I enable file upload globally.

113

Answer

Solution:

You cannot set thefile_uploads directive via.htaccess.

According to the manual,file_uploads is aPHP_INI_SYSTEM type setting. That means you can only set it via .

To enable it only for your CodeIgniter site, you can set the directive in your VirtualHost configuration by usingphp_admin_value instead ofphp_value, sincephp_value can only setPHP_INI_ALL orPHP_INI_PERDIR level settings:

<VirtualHost *:80>
    DocumentRoot /var/www/my_codeigniter_app
    # [...] all your other settings

    php_admin_value file_uploads 1
</VirtualHost>

If you don't have a VirtualHost config for your CodeIgniter site, you might be able to also set it in the<Directory> section of your Apache config (again, usingphp_admin_value), although I haven't tried that myself so I'm not 100% sure that'll work:

<Directory /var/www/my_codeigniter_app/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
    php_admin_value file_uploads 1
</Directory>

People are also looking for solutions to the problem: time - Find next recurrence of weekly event if PHP "N" date value is given

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.