Where does the browser get download title?
I am working on a site to get multiple pages of a book and m开发者_如何学编程ake it one file for mobile users. The site is at http://bookgrabber.comze.com. Right now I am providing a download link to download the finished book. The download link is actually a link to downloadBook.php. Everything works fairly well and as expected, but when you click "save link as" the first word of the title of the book comes up in the save as dialog...Where is that coming from so I can alter it? It does not appear in the html of the page...
Here is what is on the downloadBook.php page:
header('Content-disposition: attachment; filename='.$_SESSION['bookName'].'.html');
header('Content-type: application/html');
echo $_SESSION['book'];
Thank you, Todd
That's what your first header
line is designed to do: tell the browser that the file should be downloaded and not displayed, and tell it what the filename should be.
header('Content-disposition: attachment; filename='.$_SESSION['bookName'].'.html');
That filename=
part is telling the browser what the filename should be. It's getting cut off at the first space (only having the first word) because names with spaces should be surrounded by double quotes in a Content-disposition header:
header('Content-disposition: attachment; filename="'.$_SESSION['bookName'].'.html"');
精彩评论