Ikoster
Gebruiker
- Lid geworden
- 19 okt 2009
- Berichten
- 144
hallo,
ik heb (niet raar) een vraag!
ik wil met het onderstaande scriptje een bestand downloaden vanuit een map en dat lukt!
maar als je bijv een ms word bestandje download geeft hij een error en moet je iets herstellen wat niet lukt ziet iemand een fout??
:thumb: alvast bedankt!
ik heb (niet raar) een vraag!
ik wil met het onderstaande scriptje een bestand downloaden vanuit een map en dat lukt!
maar als je bijv een ms word bestandje download geeft hij een error en moet je iets herstellen wat niet lukt ziet iemand een fout??
PHP:
if(isset($_GET["f"]))
{
$file = $_GET['f'];
$file_path = "bestanden/uploads/$file";
$ext = substr($file, -3);
$content = array (
// archives
'zip' => 'application/zip',
// documents
'pdf' => 'application/pdf',
'doc' => 'application/msword',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
'ocx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'otx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
'ptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'psx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
'otx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
'lsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'ltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
// executables
'exe' => 'application/octet-stream',
// images
'gif' => 'image/gif',
'png' => 'image/png',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
// audio
'mp3' => 'audio/mpeg',
'wav' => 'audio/x-wav',
// video
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpe' => 'video/mpeg',
'mov' => 'video/quicktime',
'avi' => 'video/x-msvideo'
);
header("Content-type: $content[$ext]");
header("Content-Disposition: attachment; filename=$file");
readfile("bestanden/uploads/$file");
}
:thumb: alvast bedankt!
Laatst bewerkt door een moderator: