note 45453 deleted from features.file-upload by tomsommer

From: Date: Tue, 07 Sep 2004 21:48:08 +0000
Subject: note 45453 deleted from features.file-upload by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-76170@lists.php.net to get a copy of this message
Note Submitter: marko_[at]voxpopuli-forum[dot].net ---- <?php //__ Method to upload file (including .php file) in a public directory: //__ open temporary file $r =fopen($_FILES['your_field_name']['tmp_name'], r); $data = fread($r, filesize($_FILES['your_field_name']['tmp_name'])); fclose($r); //__ encoding base64 $data = base64_encode($data); //__ write file in directory $r = fopen($_FILES['your_field_name']['name'], w); fwrite($r, $data); fclose($r); ?> And to force download of the original file... <?php $r = fopen('name_of_stored_file', r); $file = fread($r, filesize('name_of_stored_file')); fclose($r); $file = base64_decode($file); header('Content-disposition: attachment; filename=name_of_stored_file'); header('Content-Type: application/force-download'); header('Content-Length: '.strlen($file)); print($file); ?> With this method sensible file (.php) upload is allow in public directory, in fact php analyser don't understand base64 encoded file ;-) marko_

« previous php.notes (#76170) next »