473,385 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Bailing after outputting file

127 100+
Hi all,

I have a PHP script that is split into 2 parts; first, the user input is analyzed and a txt file is made; second, the remainder of the script generates some HTML output that is displayed.

It looks like the HEADER stuff for the txt file causes the script to stop after the file is produced, and the remainder of the script isn't run. Is there any work around?

Expand|Select|Wrap|Line Numbers
  1.    $filename = "output";
  2.    $ext = "txt";   // file extension
  3.    $mime_type = (PMA_USR_BROWSER_AGENT == 'IE' || PMA_USR_BROWSER_AGENT == 'OPERA')
  4.    ? 'application/octetstream'
  5.    : 'application/octet-stream';
  6.    header('Content-Type: ' . $mime_type);
  7.    if (PMA_USR_BROWSER_AGENT == 'IE')
  8.    {
  9.       header('Content-Disposition: inline; filename="' . $filename . '.' . $ext . '"');
  10.       header("Content-Transfer-Encoding: binary");
  11.       header('Expires: 0');
  12.       header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  13.       header('Pragma: public');
  14.    } else {
  15.       header('Content-Disposition: attachment; filename="' . $filename . '.' . $ext . '"');
  16.       header("Content-Transfer-Encoding: binary");
  17.       header('Expires: 0');
  18.       header('Pragma: no-cache');
  19.    }
  20.  
Thanks!
Oct 14 '09 #1
1 1309
dlite922
1,584 Expert 1GB
You can't give the user two things at once. First create and save the txt file, output the HTML, giving them the a link or auto forward to the txt file that was created.

You can have PHP change the headers so when you auto forward, the browser does not display the content, but instead gives the user an Open/Save/Cancel prompt.


Cheers,



Dan
Oct 14 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Jonathan | last post by:
I have a client solution that requires data and associated files to be stored with data in a database. As such, I have a situation where JPEG thumbnails/images that are stored as BLOBs (image...
5
by: Andrei Pociu | last post by:
I have a major doubt about outputting text in ASP .NET when using code behind. I know most of the output you gain from a code behind file (.aspx.cs) is outputted to the Webform (.aspx) using...
13
by: Jacek Dziedzic | last post by:
Hello! I have a piece of code that needs to display a formatted table of pointers using streams, with the pointers represented as hex values. It looks more or less like this: #include...
2
by: Andy | last post by:
Hi I'm really stuck outputting a double number to the console with three decimal places if the furthest right value is a zero. I can coutput the number 4.546 as 4.546 but then if I output...
2
by: cephelo | last post by:
I have no problems outputting the attribute value when the node is in context, for example, @id when an <status> node is in context. However, I am having trouble outputting it in a <xsl:value-of...
0
by: Heather Barber | last post by:
Hi So I'm fine with outputting to file from C#. But... as soon as I create an executable and move the file it no longer works - in fact it crashes due to security settings of some sort - whereever i...
4
by: Peter Nimmo | last post by:
Hi, I am writting a windows application that I want to be able to act as if it where a Console application in certain circumstances, such as error logging. Whilst I have nearly got it, it...
5
by: phong.lee | last post by:
Hello all, I was wondering if someone can assist me in outputting 6 reports into a pdf file? I created a macro that generates the 6 reports and right now it's saved as a snapshot on my drive. ...
3
by: mohaakilla51 | last post by:
Alright guys, I am working on a flashcard script... Previously I had it so that it onlty had predefined categories. People were complaining, so now I am trying to make it to where it reads...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.