- Home
- Categorie
- Coding e Sistemistica
- PHP
- creare zip con nome
-
creare zip con nome
Ciao a tutti,
ho scaricato questo bellissimo directory manager: ecosmear.com/relay/
Il punto è che quando si fa il download dei file caricati, crea uno zip sempre con lo stesso nome: package.zip.
Credo che il problema sia nel file relay.php che copio:[....] function getFilePackage($fileids,$returnContent = false){ global $database,$fileinfo,$filepath; $fileids = preg_split("/\,/",$fileids); include_once("inc/createZip.inc.php"); $createZip = new createZip; $fileCount = 0; logAction('getFilePackage',$fileids); foreach($fileids as $fileid){ if(getFileInfo($fileid)){ if(getUserAuth('download',$fileinfo['virtualpath'])){ logAction('get',$fileid); $query = "update $GLOBALS[tablePrefix]filesystem set downloads=downloads+1 where id=$fileid"; $result = mysql_query($query,$database); $createZip -> addFile(file_get_contents($filepath), "$fileinfo[filename]"); $fileCount++; }else{ // denied } }else{ // denied } } if($fileCount > 0){ if($returnContent != true){ header("Content-Type: application/zip"); header("Content-Transfer-Encoding: Binary"); #header("Content-length: ".strlen($zipped)); header("Content-disposition: attachment; filename=\"package.zip\""); echo $createZip -> getZippedfile(); }else{ return $createZip->getZippedfile(); } }else{ error('no files zipped'); } } [.....] ```Io vorrei invece che il nome dello zip fosse uguale al nome del file altrimenti è un casino. Chi sa aiutarmi? Grazie
-
Prova cosi:
[php]
[....]
function getFilePackage($fileids,$returnContent = false){
global $database,$fileinfo,$filepath;$fileids = preg_split("/\,/",$fileids); include_once("inc/createZip.inc.php"); $createZip = new createZip; $fileCount = 0; logAction('getFilePackage',$fileids); foreach($fileids as $fileid){ if(getFileInfo($fileid)){ if(getUserAuth('download',$fileinfo['virtualpath'])){ logAction('get',$fileid); $query = "update $GLOBALS[tablePrefix]filesystem set downloads=downloads+1 where id=$fileid"; $result = mysql_query($query,$database); $createZip -> addFile(file_get_contents($filepath), "$fileinfo[filename]"); $fileCount++; }else{ // denied } }else{ // denied } } if($fileCount > 0){ if($returnContent != true){ header("Content-Type: application/zip"); header("Content-Transfer-Encoding: Binary"); #header("Content-length: ".strlen($zipped)); header("Content-disposition: attachment; filename=\"$fileinfo[filename]
"");
echo $createZip -> getZippedfile();
}else{
return $createZip->getZippedfile();
}
}else{
error('no files zipped');
}}
[.....]
[/php]
-
Così funziona benissimo, scarico il file con il nome originario.. l'unica è che non mi crea lo zip .. ma se non si può fare diversamente va benissimo..
Grazie Thedarkita
-
Come non detto, lo script è fighissimo, ma quando provo a scaricare file di grandi dimensioni ne scarica solo pochi kb..
Peccato..