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
Message is not displaying after downloading the file
Jun 3 2020 2:27 AM
$msg=DisplayMsg();
if
($msg)
{
try
{
$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];
if
(file_exists($path))
{
header(
'Content-Description: File Transfer'
);
header(
'Content-Type: application/pdf'
);
header(
'Content-Disposition: attachment; filename="'
.$path.
'"'
);
header(
'Expires: 0'
);
header(
'Cache-Control: must-revalidate'
);
header(
'Pragma: public'
);
header(
'Content-Length: '
. filesize($path));
ob_clean();
ob_flush();
readfile($path);
}
}
catch
(Exception $e) {
echo
'Caught exception: '
, $e->getMessage(),
"\n"
;
}
}
<?php
function
DisplayMsg()
{
$val
=
""
;
try{
echo
"<h4 class='alert alert-success'>Thank you for downloading story</h4>"
;
}
catch(Exception
$e
)
{
}
return
$val
=
"success"
;
}
?>
Reply
Answers (
1
)
How to build logic
download file and redirect to page