Minggu, 17 November 2013

PHP Indonesia - Facebook: Assalamulaikum..Selamat Pagi agan-agan... ane udah...

PHP Indonesia - Facebook
PHP Indonesia is a community for everyone that loves PHP. Our focus is in the PHP world but our topics encompass the entire LAMP stack. Topics include PHP coding, to memcached handling, db optimizations, server stack, web server tuning, code deploying, hosting options and much much more. Youtube Channel : http://www.youtube.com/user/OurPHPIndonesia Twitter : @php_indonesia NOTE: Rules for Wall posting: https://www.facebook.com/groups/35688476100/doc/10151597056316101/ Daftar Keanggotaan : http://www.facebook.com/groups/35688476100/doc/10150671770741101/ 
Compare Hotels

Find great prices for amazing hotels wherever your next destination may be. It's simple to search 100+ sites at once!
From our sponsors
Assalamulaikum..Selamat Pagi agan-agan... ane udah...
Nov 17th 2013, 22:45, by Ayat Hidayat

Ayat Hidayat 10:45pm Nov 17
Assalamulaikum..Selamat Pagi agan-agan...
ane udah coba nih coding untuk download beberapa file lalu di .zip,
tapi kog gk konsisten gan antara file yg di pilih untuk di download dengan hasilnya yg udah di .zip ???
ane pake cek box untuk download per barisnya...
smoga ada pencerahan.. Terima Kasih, smoga Berkah...

Ayat Hidayat 10:47pm Nov 17
ini koding untuk tampilan file2 yg akan di download, Point cekbox nya ada pada tag <td> yg kedua gan, :

while ($data=mysql_fetch_array($hasil))
{
?>
<tr>
<td><a href="delete-file-mhs-web.php?id=<?php echo $data['id'];?>" onclick="return confirm('Anda yakin menghapus file dengan NIM <?php echo $data['nim_mhs'];?> ?');">
<i class='icon-trash'></i>Hapus</a>&nbsp;
<a href="download-single.php?id=<?php echo $data['id'];?>">
<i class='icon-download'></i>Download</a>
</td>
<td><input type="checkbox" name="data[]" value="<?php echo $data['id'];?>"/></td>
</tr>
<?php
}

Ayat Hidayat 10:51pm Nov 17
ini file untuk proses submit pilihan2 tadi (Sumber dari webinfopedia.com) :

<?php
//This script is developed by www.webinfopedia.com
//For more examples in php visit www.webinfopedia.com
function zipFilesAndDownload($file_names,$archive_file_name,$file_path)
{
$zip = new ZipArchive();
//create the file and throw the error if unsuccessful
if ($zip->open($archive_file_name, ZIPARCHIVE::CREATE )!==TRUE) {
exit("cannot open <$archive_file_name>\n");
}
//add each files of $file_name array to archive
foreach($file_names as $files)
{
$zip->addFile($file_path.$files,$files);
//echo $file_path.$files,$files."<br />";
}
$zip->close();
//then send the headers to foce download the zip file
$zipped_size = filesize($archive_file_name);
header("Content-Description: File Transfer");
header("Content-type: application/zip");
header("Content-Type: application/force-download");// some browsers need this
header("Content-Disposition: attachment; filename=$archive_file_name");
header("Expires: 0");
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
//header('Pragma: public');
header("Pragma: no-cache");
header("Content-Length: ".$zipped_size);
ob_clean();
flush();
readfile("$archive_file_name");
unlink("$archive_file_name"); // Now delete the temp file (some servers need this option)
exit;
}

if (isset($_POST['bt_download'])) {
include "../../koneksi.php";
//$data=$_POST['data'];
$data=filter_var_array($_POST['data']);//works but it's the wrong method
for ($i=0;$i < sizeof($data); $i++){
$sql="select * from file where id in('$data[$i]')";
//Mysql query to fetch file names
$query=mysql_query($sql);
//create an empty array
$file_names = array();
//fetch the names from database
while($row = mysql_fetch_array($query, MYSQL_NUM)){
//Add the values to the array
//Below 3 ,eams the the number of the mysql table column
$file_names[] = $row[3];
}
$namafile=date("d-m-y");

//Archive name
$archive_file_name="File-Praktikum-Web-Klp.".$row['kelompok']."-".$namafile.".zip";
//Download Files path
$file_path='../file_mhs/';
}
//call the function
zipFilesAndDownload($file_names,$archive_file_name,$file_path);
}
?>

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions

Tidak ada komentar:

Posting Komentar