Re: upload_max_filesize hack

From: Date: Tue, 24 Dec 2002 22:25:57 +0000
Subject: Re: upload_max_filesize hack
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-129311@lists.php.net to get a copy of this message
i just cleaned it up a bit <? function edit_max_filesize($size){ $filename = ".htaccess"; $size = $size."M"; $fd = fopen ($filename, "r+"); flock($fd, LOCK_EX); while (!feof($fd)) { $fpos = ftell($fd); $c = fgetc($fd); if ($c == "M"){ ftruncate($fd, $fpos-2); fseek($fd, -3, SEEK_CUR); fwrite($fd,'"'.$size.'"'); } } flock($fd, LOCK_UN); fclose ($fd); } define('MAX_FILESIZE','5'); edit_max_filesize(MAX_FILESIZE); ?> "Electroteque" <daniel@electroteque.org> wrote in message news:20021224222213.51562.qmail@pb1.pair.com... > hi guys i've managed to edit a htaccess file which will allow to override > the upload_max_filesize ini setting which cannot be edited in php itself > hope this helps, shure its a hack there could be anything with M in it, i'm > terrible at regex, so if anyone would like to add to it go ahead. > > <? > $filename = ".htaccess"; > $fd = fopen ($filename, "r+"); > flock($fd, LOCK_EX); > while (!feof($fd)) { > $size="3M"; //whatever value u like in a defines > $fpos = ftell($fd); > $c = fgetc($fd); > if ($c == "M"){ > ftruncate($fd, $fpos-2); > fseek($fd, -3, SEEK_CUR); > fwrite($fd,'"'.$size.'"'); > } > } > flock($fd, LOCK_UN); > fclose ($fd); > ?> > >

« previous php.general (#129311) next »