php - Make multiple files to force-download -


sorry if title doesn't explain much. let me try explain further.

i have code looks this:

<? //grab number in count.txt $count = intval(file_get_contents('count.txt')); //move number 1 file_put_contents('count.txt', ++$count); $number = file_get_contents('count.txt'); //force download header('content-disposition: attachment; filename=datafiles'.$number.".csv"); header('content-type: application/octet-stream');  //the data  foreach($array $info){ echo $info."\n"; } ?> 

with $array being array of data.

now amount of data can more 5000, if data on 5000, make file every 5000 data being echoed. ea: if there 20,000 pieces of data in $array, make total of 4 files.

you cannot send more 1 file in response http request.

what suggest zip file in single file , return that.

see: download multiple files zip-file using php


Comments