Fungsi download PHP

function download($id){
$data['file'] =$this->MFile->getFileById($id);//
// tempat dimana file berada misal C:\xampp\htdocs\apotek\berkas\20126\gambar.jpg
//C:\xampp\htdocs\apotek\[namaPath]\[namaFile]
$download = file_get_contents(realpath($data['file'][0]['path']."/".$data['file'][0]['nama']));
$name = $data['file'][0]['nama']; // Kalo ingin dirubah nama file nya
force_download($name, $download);
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: