Forum Moderators: coopster

Message Too Old, No Replies

Trying to enable file uploads on a PERDIR basis

Does PHP v.5.x allow this? file_uploads is in the PHP_INI_SYSTEM class...

         

StupidScript

11:42 pm on Aug 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PHP v.5.0.4, Apache 2.0.4, Fedora Core 4 (SELinux)

In php.ini:

file_uploads = Off

upload_max_filesize = 2M

In httpd.conf:

<Directory "/some/dir">

 AllowOverride All

</Directory>

In "/some/dir" .htaccess (chmod 644):

php_flag file_uploads on

php_value upload_max_filesize 4M

The result:

file_uploads = Off
within "/some/dir/"
upload_max_filesize = 4M
within "/some/dir/"

I've tried:

<Directory "/some/dir">

 AllowOverride All

 php_flag file_uploads on

</Directory>

in httpd.conf, and:

<IfModule mod_php5.c>

 php_flag file_uploads on

</IfModule>

in both httpd.conf and .htaccess, but I just can't get

file_uploads
enabled on a PERDIR basis.

Also tried

php_flag file_uploads 1
and
php_flag file_uploads "1"
and
php_value file_uploads "On"
in all of the above scenarios with no joy.

Does PHP v.5.x never allow file_uploads on a PERDIR basis? I noted in the docs that it was allowable on a SYSTEM basis, which is why I figured I'd try the httpd.conf hack, to no avail.

What am I missing, here? TIA.

coopster

12:34 pm on Aug 3, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



php_flag file_uploads on
is it. Yes, as of PHP > 4.2.3 it must be set in either
php.ini
or
httpd.conf
. It cannot be overridden in per-directory override files (
.htaccess
).

Make sure you don't have other overrides in your configuration file(s) that are not allowing otherwise (are you using some type of control panel?)

Also, don't forget to restart Apache or the configuration file is not going to be in effect.

StupidScript

9:07 pm on Aug 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for the reply, coopster. (root ssh access)

Got the answer, amusingly enough from a closer reading of the PHP manual [php.net]! (doh)

php_flag name onŠoff
Used to set a boolean configuration directive. Can be used only with PHP_INI_ALL and PHP_INI_PERDIR type directives.

Since

file_uploads
is a PHP_INI_SYSTEM type directive as of PHP v.5.x, I needed to use these in my httpd.conf file:

<Directory "/some/dir">

[b]php_admin_flag[/b] file_uploads on

php_value upload_max_filesize 4M

</Directory>

(Not allowed to use PHP_INI_SYSTEM type directives in .htaccess files, just in php.ini or httpd.conf, as you noted.)

After a restart, I'm all set and allowing file uploads with a greater filesize limit than set in php.ini on a per-directory basis.

Thanks again!

[edited by: StupidScript at 9:09 pm (utc) on Aug. 3, 2006]

coopster

9:30 pm on Aug 3, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Must have been too early when I posted this morning because I was going to mention that, SS ;) Glad you got it sorted and thanks for the follow-up -- future searchers/readers will certainly appreciate it!