note 46505 deleted from function.base64-decode by tomsommer

From: Date: Wed, 13 Oct 2004 16:05:27 +0000
Subject: note 46505 deleted from function.base64-decode by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-78502@lists.php.net to get a copy of this message
Note Submitter: webmaster at technotoad dot no5pam dot com ---- I had the task of base64 decoding a large (>1Mb) file, and PHP fell over on my server when trying to base64 decode such a lot of data in one go. I found that you could cut the file into smaller chunks, decode them individually and recombine to form a decoded file. This worked as long as the size of each chunk was divisible by 4, as base64 encodes in 4 character groups. <?php #open input and output files $infile = fopen($input_file_name, "r"); $outfile = fopen($output_file_name, "w"); #step through input file while (!feof($infile)) { #get a 1024 byte (256*4) piece of infile $line = fread($infile, 1024); #base64 decode it and write it to outfile fwrite ($outfile,base64_decode($line)); } #close the files fclose ($infile); fclose ($outfile); ?>

« previous php.notes (#78502) next »