Salve,
ho la necessità di dover consentire agli utenti che si collegano ad un sito di poter far scaricare in locale dei file presenti come allegati sul server. Ho tentato attraverso il codice:
----------------------------
switch ($estensione):
case 'jpg':
$ctype = "Content-Type: image/jpeg";
break;
case 'gif':
$ctype = "Content-Type: image/gif";
break;
case 'png':
$ctype = "Content-Type: image/x-png";
break;
case 'tiff':
$ctype = "Content-Type: image/tiff";
break;
case 'html':
$ctype = "Content-Type: text/html";
break;
case 'rtf':
$ctype = "Content-Type: application/rtf";
break;
case 'pdf':
$ctype = "Content-Type: application/x-pdf";
break;
case 'ppt':
$ctype = "Content-Type: application/vnd.ms-powerpoint";
break;
case 'xls':
$ctype = "Content-Type: application/vnd.ms-excel";
break;
case 'doc':
$ctype = "Content-Type: application/msword";
break;
case 'zip':
$ctype = "Content-Type: application/x-zip";
break;
case 'swf':
$ctype = "Content-Type: application/x-shockwave-flash";
break;
endswitch;
$filename= $nome_file . "." . $estensione;
header ($ctype);
header ("Content-Disposition: attachment; filename=$filename");
$percorso = "../mia_cartella/" . $filename;
include($percorso);
---------------------
Il codice sembrerebbe funzionare per i file immagine, per i filmati flash e per le applicazioni MS. Purtroppo i file pdf e zip sembrerebbero deteriorarsi con il download, non riuscendo ad aprirli dopo la procedura. Sarei grato a tutti coloro che potessero darmi qualche indicazione su come consentire all'utente di potre scaricare i file anche di tal tipo. Grazie anticipatamente.