You can configure upload_max_filesize via .htaccess

2

Is it possible to configure php upload_max_filesize by .htaccess file? Since I do not have access to the php.ini file from the server.

    
asked by anonymous 18.02.2016 / 11:22

3 answers

3

To complement the other answer, to use configuring php through .htaccess, you must have mod_php installed on your server, if your server or hosting does not have availability, an error message will appear on all error pages 500 Internal Error Server , similar to this:

Ifyourhosting/serverallowsyoutoinstallthingsperterminal(ssh)youcantrysomethinglike(beingDebianorUbuntu):

sudoapt-getinstalllibapache2-mod-php5

Notethatyouwillneedtorestarttheserver,howeverifyoudonothaveaccesstoSSHthenyouwillhavetocontactsupporttoenable.

Seethedifferencesinmod_phpsettings:

  • php_flagisusedwhenthereareBooleanvalues,whichsettingsofphp.inithatonlyaccept1or0,OnorOffandtrueorfalse,forexample:

    php_flagdisplay_startup_errorsoffphp_flagdisplay_errorsoff
  • php_valueisusedwhenitisnotaboutturningonoroff(likeOnandOff),inthecaseweusewecanusetodefinepathsandlimitsinmegabytes,

    php_valueupload_max_filesize25Mphp_valueerror_log/foo/bar/baz/erros.log
  • php_admin_flagcannotbeusedin.htaccess,youcanonlyconfigureitinApacheandthisallowsyoutooverwritewhichphp.iniconfiguration,differentfrompreviousonesthathaslimitations.>

Itisalsointerestingtonotethatmanyserversdonotletyoueditphp.inianddonothavemod_phpbuttheyhavetheoptionofeditingafileonthelocaluserthatoverwritessomeflags
18.02.2016 / 16:43
2

According to this site it does.

Just add this to your .htacess :

#configuração php
php_value  upload_max_filesize  10M

Also another good reference is here in this SOEN question

    
18.02.2016 / 11:24
1

You can use the ini_set() function in PHP! Just put the contents of the .ini line as a parameter:

<?php
ini_set("upload_max_filesize", "10000");

Doc: link

    
22.02.2016 / 19:27