i using laravel 4.2 , looking setup area zip file produced user download.
i keep getting error
the file "myzip.zip not exist"
my current code :
// here choose folder used. $dirname = public_path() . '/uploads/packs/'.$pack_id; // choose name archive. $zipfilename = 'myzip.zip'; // create "mycoolname.zip" file in public directory of project. $zip = new ziparchive; if ( $zip->open( public_path() . '/' . $zipfilename, ziparchive::create ) === true ) { // copy files folder , place them in archive. foreach ( glob( $dirname . '/*' ) $filename ) { $file = basename( $filename ); $zip->addfile( $filename, $file ); } $zip->close(); $headers = array( 'content-type' => 'application/octet-stream', ); // download .zip file. return response::download( public_path() . '/' . $zipfilename, $zipfilename, $headers );
can me, why getting not exist error?
thank you!
from laravel documentation: http://laravel.com/docs/4.2/responses#special-responses
creating file download response
return response::download($pathtofile); return response::download($pathtofile, $name, $headers);
maybe should avoid repeat second
$zipfilenamein last line of code.
Comments
Post a Comment