473,811 Members | 3,264 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Saving a file and showing file information.

I am trying to do two things at a time. I want to give the user the
opportunity to save a file and at the same time see new information on
the screen.

I can do it seperately, but not together. What I have is the following:

@ob_end_clean() ;
$SHOW = "1";
if ($SHOW == 1) {
// Show all the info on a page
$TEXT = $TEXT."<pre>".$ LINE."</pre>"; // $TEXT = website data
// $LINE = new content
include("../main_text2.inc" ); // HTML Layout
} else {
// Save the file
$length = strlen($LINE);
header('Last-Modified: '.date('r'));
header('Accept-Ranges: bytes');
header('Content-Length: '.$length);
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$fi lename.'.itn"') ;
print $LINE; // $LINE = new content
}

When I change the "1" into a "0" it will save the file. So sperately
this works, but together it doesn't. When I try it together I get the
error with each header: <b>Warning</b>: Cannot modify header
information - headers already sent by (output started at header.inc:3)
in <b>test02.php </bon line <b>133</b><br />

header.inc (which is an include in main_text2.inc) cointains:
<html>
<head>
<title><?php print $TITLE; ?></title>
<link rel="stylesheet " title="Shell (Default)" type="text/css"
href="/style.css" media="screen">
<link rel="alternate stylesheet" title="Newer" type="text/css"
href="/new_style.css" media="screen">
</head>
<body>
<div id="page">
So what can I do do first show the info and when the page is loaded give
the visitor the ability to save the file?

houghi
--
> Beware of he who would deny you access to information, <
for in his heart he dreams himself your master. <
Commissioner Pravin Lal: "U.N. Declaration of Rights" <
Nov 16 '08 #1
2 1682
houghi wrote:
I am trying to do two things at a time. I want to give the user the
opportunity to save a file and at the same time see new information on
the screen.

I can do it seperately, but not together. What I have is the following:

@ob_end_clean() ;
$SHOW = "1";
if ($SHOW == 1) {
// Show all the info on a page
$TEXT = $TEXT."<pre>".$ LINE."</pre>"; // $TEXT = website data
// $LINE = new content
include("../main_text2.inc" ); // HTML Layout
} else {
// Save the file
$length = strlen($LINE);
header('Last-Modified: '.date('r'));
header('Accept-Ranges: bytes');
header('Content-Length: '.$length);
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$fi lename.'.itn"') ;
print $LINE; // $LINE = new content
}

When I change the "1" into a "0" it will save the file. So sperately
this works, but together it doesn't. When I try it together I get the
error with each header: <b>Warning</b>: Cannot modify header
information - headers already sent by (output started at header.inc:3)
in <b>test02.php </bon line <b>133</b><br />

header.inc (which is an include in main_text2.inc) cointains:
<html>
<head>
<title><?php print $TITLE; ?></title>
<link rel="stylesheet " title="Shell (Default)" type="text/css"
href="/style.css" media="screen">
<link rel="alternate stylesheet" title="Newer" type="text/css"
href="/new_style.css" media="screen">
</head>
<body>
<div id="page">
So what can I do do first show the info and when the page is loaded give
the visitor the ability to save the file?

houghi

Any particular page request from the browser can only have one content
type and content disposition. You're trying to get two different ones
for the same file, which is not allowed.

To do what you want, you need the browser to make two different requests
and load two different files. Try alt.html to find out how to do it
from the html end, and put your code to generate the data to be saved in
another file.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Nov 16 '08 #2
Jerry Stuckle wrote:
Any particular page request from the browser can only have one content
type and content disposition. You're trying to get two different ones
for the same file, which is not allowed.
OK. :-(
To do what you want, you need the browser to make two different requests
and load two different files. Try alt.html to find out how to do it
from the html end, and put your code to generate the data to be saved in
another file.
Bummer, but thanks. Atr least I now do not loose any extra time looking
for a solution that isn't there.

houghi
--
> Beware of he who would deny you access to information, <
for in his heart he dreams himself your master. <
Commissioner Pravin Lal: "U.N. Declaration of Rights" <
Nov 16 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
7531
by: G-Factor | last post by:
Hi all I've just started learning about saving files. I got bit of a problem. The following code gives me an error about incompatible types. (Cannot covert from class character to char *). I would appreciate it if anyone could either help me out, or direct me to an online resource site that has information on saving/loading classes. I have found several tutorials, but they either do not really help (saving text files) or are too...
4
3308
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any errors. After reading the ole object from db, I saved it to C: as file1.bmp and displayed on the web. But it can not be displayed. After I manually sent the file to wordpad, it shows
1
1242
by: Stephajn Craig | last post by:
I've got an application that many supervisors are going to use. However, each one needs to see a different part of the information. Some supervisors will all have the same view of the information with the same fields showing. Others have variations on those fields to see. The idea is that when an error is made in a certain business process, a log entry of it would be made. The department responsible would have its supervisor notified...
15
1523
by: Dan DeConinck | last post by:
Hello, I want to save the position of all the controls on my form. I would like to write them out to a preference file. I have done this in DOS BASIC like this: TO WRITE the preference open "c:\preferences.txt" for input as #1 input #1 ,a,b,c
1
2000
by: M Keeton | last post by:
I currently have a picture which is stored in a "System.Drawing.Image" variable and I want to save it as a bitmap file. I have tried 2 different approaches and both give me the following error: An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in system.drawing.dll Additional information: A generic error occurred in GDI+.
5
4736
by: TheGanjaMan | last post by:
Hi everyone, I'm trying to write up a simple image stamper application that stamps the Exif date information from the jpegs that I've taken from my digital camera and saves the new file with the date stamped on the lower right part of the picture. (I'm not an advanced programmer so my code may not be 100% efficient - sorry, I'm still learning) Everything works fine until the saving part. I've been able to read the file into a...
2
2523
by: Mark Denardo | last post by:
Hi, I need some expert GDI+ person to help me with my RoundOffImage Function: What I'm trying to do is take in an image, crop off the edges around an ellipse region I set up, and then return the cropped image from the function. I sort of have this working, but not thoroughly. If I take the output image of this function and draw it on my form it shows the clipped image as transparent as I am wanting it. But if I take that image and...
2
1843
by: chiefsitebuilder | last post by:
I have a question about saving an MS Access program to CD and verifyng that the program works after being saved. Here is my situation, I have a person who developed an application for me using MS Access 2003 and the person will be transferring ownership to me. The developer will be giving me a CD with Access DBase source code on it. How do I verify that he gives me everthing I need to run the application once the developer departs. ...
6
2145
by: PetyaNic | last post by:
Hello, I'm a very beginner in Javascript and sorry if my question sounds stupidly. I want to print a page without showing the print window and without saving the page as a file. I want the user only to click a button and the page to be printed on the default printer. Is it possible?
0
9727
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10647
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10386
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10398
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10133
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9204
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6889
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
3017
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.