Jump to content

File download script problem!


know_php

Recommended Posts

 

I am using this script for downloading of a file, but it doesnt do anything when i click on download.

 

header("Content-Disposition: attachment; filename=$name");

header("Content-length: $size");

header("Content-type: $type");

 

Please suggest way to do it successfully.

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/78214-file-download-script-problem/
Share on other sites

Like

<?php 
session_start();
ob_start();
include("include/userconfig.php");
// here i am downloading PDF 
$filepath="userdownloads/myfile.pdf";;
$filename="myfile.pdf";

downloadFile($filename,$filepath);
function downloadFile($filename,$filepath)
{
header("Content-type: application/pdf"); 
header("Content-disposition: attachment; filename=".$filename); 
header("Content-Length: " . filesize($filepath));
header("Pragma: no-cache"); 
header("Expires: 0"); 
readfile($filepath); 

return;
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.