TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Shiva Tiwari
NA
73
5.2k
download file and redirect to page
Jun 4 2020 2:02 AM
$select = "SELECT * FROM `success-stories` where id='$id'";
$result = $conn->query($select);
$row = $result->fetch_assoc();
$file = $row["download_pdf"];
$file_arr = explode("/", $file);
$path = $file_arr[0] . "/" . $file_arr[1] . "/" . $file_arr[2];
header('Content-Description: File Transfer');
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
header('Expires: 0');
header('Pragma: no-cache');
header('Content-Length: ' . filesize($file));
$file1 = $path;
// this doesn't really matter.
$fp = fopen($file1, "r");
while (!feof($fp)) {
echo fread($fp, 65536);
flush(); // this is essential for large downloads
}
fclose($fp);
header("location:download-form.php?msg=story downloaded");
Reply
Answers (
1
)
Message is not displaying after downloading the file
How to get textbox value into php query from javascript & html