I know how to make the download occur, when the download happens it appends the html from the web page that causes the download. How do I filter out the HTML?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
If I understand you correctly it's a common problem. I solved it by using ob_start at the beginning of my index.php (start/root/entry file) before ANY output occures and for the download I do the following:
Update
The
ob_start
command buffers any output (eg via echo, printf) and prevents anything being send to the user BEFORE your actual download. Theob_end_clean
than stops this behavior and allows direct output again. HTH.Make sure you're not outputting additional data after the file stream is completed. Use a call to exit() to end page execution after the file stream is finished. Any characters after a closing '?>' tag (such as a newline) can cause download problems as well.
Moving the download script to its own file should make finding any problems easier, because it does only one thing. To avoid outputing any final newlines, you can omit the closing '?>' tag in this case as well at the end of your script.
I understand that you're trying to output some stream for download from PHP page?
If so, then don't output that content from the page that contains HTML, but redirect to separate php page that outputs only the download stream, with headers if necessary.