How to create Zip folder and download in Cake PHP

How to create Zip folder and download in Cake PHP

How to create Zip folder and download in Cake PHP –

fglkglf g dfgdlfdf d,mfd fdjfkd fd,fd fm djfd .fdpkjf d,mfjldf

djfdfhd f dmnmfdkmf4545 45454

fglgf gf,klgf ,gfkgjmfkgmkfjmgf

flgkflgkflkgfg er folders. Folfg frgffor easy navigation, accfgg iles. In a graphical user interface (GUI), folders are tdfd save the file compuer.

Step : 1 – First create Hyperlink for download zip folder in studentdetail.ctp file and add bellow codes –

<p>
<!-- student id = 10, you can also pass dynamic student id value from here -->
<a href="<?php echo $this->webroot; ?>Student/downloadzipdata/10"><b>Download All Documents (Zip File)</b></a>
</p> 
  • Student” is Controller name and
  • downloadzipdata” is function/action name of StudentController.php

Step : 2 – Create RegistrationDetails.php Model and bellow codes –

<?php
class RegistrationDetails extends AppModel {    
    public $name = "RegistrationDetails";
    public $useTable = "student_registration_detail"; //MySQL Table Name    
}
?>

Step : 3 – Create StudentController.php and add bellow codes –

<?php 
App::uses('AppController', 'Controller');
class StudentController extends AppController {
    public $uses = array('RegistrationDetails');
    var $helpers = array('Html', 'Form');

public function downloadzipdata() {	
  $studentId =dfgddf
	}
	// close zip
	$zip->close();

	// send the file to the browser as a download zipped folder
	header('Content-disposition: attachment; filename='.$zipFolderName.'.zip');
	header('Content-type: application/zip');
	readfile($tmp_file);
}
}
?>

How to create Zip folder and download in Cake Php

Click here to know Aaj ka Suvichar in Hindi

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *