Tags
PHP
Asked 8 years ago
14 Oct 2016
Views 1254
sandip

sandip posted

how to disable upload at LAMP server ?

i want to get rid of uploading any file to my server by the php files.
is there any way of by php.ini or .htacess or any other server modification so i can disable uploading of files to users ?
main reason is My wordpress site got infected. i got index.php file have following some code with eval function which is undesirable

eval(gzinflate(base64_decode("HZ3fdsfHjtfvdqlkdsfabf5Y7OAQfMCRc9YKaYc5o0mHOmmJ6+ .... ));


i am cleaning daily but still it get infected .
so i want to limit the cause of the get it infected daily.
so i find that it should be uploaded from somewhere so i want to get rid of the upload function of my server.
Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00

you can do it by php.ini
file_uploads = off

or other some case where shared host you can do it php function as well
ini_set('file_uploads', 'off'); 

Note : you can use 0 instead word 'off' as well at both in php.ini or at ini_set to disable file upload



when you want to enable use on or 1 file_uploads = on or ini_set('file_uploads', 'off');
more detail at
http://php.net/manual/en/ini.core.php#ini.file-uploads
ini_set('file_uploads', 'off'); not working . means it still upload if you off file_uploads by ini_set function - sandip  
Oct 16 '16 06:07
its true ini_set('file_uploads', 'off'); will not work . because its already passed to scrip before ini_set function change it so it take default value of php.ini - ravi  
Oct 16 '16 06:15
Mahesh Radadiya

Mahesh Radadiya
answered Nov 30 '-1 00:00

you can also set file_uploads = off with httpd.conf also if you are using Apache server .


You can not set file_uploads = off with .htacess because file_uploads is PHP_INI_SYSTEM type directives , PHP_INI_SYSTEM type directive cant be changeable by .htacess

put this code at httpd.conf file after loading module of the php.

<IfModule php5_module>
php_flag file_upload off 
</IfModule>

find the code of load module . search for below "LoadModule" . i have following line used at httpd.conf to load php

LoadModule php5_module "D:/archirayan/wamp/bin/php/php5.2.9-2/php5apache2_2.dll"

LoadModule is used for any module load at Apache . above is line for php 5 module load on Apache. i copied from my wamp so it is using php5apache2_2.dll . if you using Linux , you have .so file there . but no worry , point is here php5_module is the module alias and i used it in IfModule so put IfModule code as above after the load module

i suggesting this solution but not tested untill now .
Post Answer