473,386 Members | 1,766 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,386 software developers and data experts.

Save file as attachment

Hi!

I talked about this some time ago somewhere else, now I am working
with this again...

I want to offer the user to save/open a file, instead of the browser
opening it by itself (as e.g. a jpeg picture would).
Looking into the advices I got at the time, I came up with this:

<?php
$filename=ExtractFileName($file); // my own function included here

header('Content-type: application/octet-stream');
header("Content-Disposition: attachment; filename=\"$filename\"");
readfile($file);
?>

It works, I get the dialog, but the white window remain.

What options do I have of closing the window, so I only have the
dialog?
My email at www.hot.ee has that option, some odd link (/attn/hex-code-
here ) which behaves as I'd like mine too.

What would people around here do?

BR
Sonnich

Mar 27 '07 #1
3 6167
If the link that sends the user to the page with your PHP code on it
has the target as a new window (i.e <a href="download.php"
target="_blank">) then the new window will open and you will see the
dialog box in front of a empty window (i.e the white you are seeing).

If you make the link stay within the same browser window (i.e <a
href="download.php"with no target) then it should just open the
dialog box with the current browser window in the background.

It is because you are not sending new HTML for the current browser
window so it has no information for updating so it stays the same.

I think that is what you were looking for but if not then please
clarify a little more.

Jeff

Mar 27 '07 #2
On Mar 28, 12:22 am, "Jeff" <j...@quixion.netwrote:
If the link that sends the user to the page with your PHP code on it
has the target as a new window (i.e <a href="download.php"
target="_blank">) then the new window will open and you will see the
dialog box in front of a empty window (i.e the white you are seeing).

If you make the link stay within the same browser window (i.e <a
href="download.php"with no target) then it should just open the
dialog box with the current browser window in the background.

It is because you are not sending new HTML for the current browser
window so it has no information for updating so it stays the same.

I think that is what you were looking for but if not then please
clarify a little more.
No need to. Seems like you understood it the way it is. I'll test that
later today.

BR
Sonnich

Mar 28 '07 #3
On Mar 28, 10:08 am, "jodleren" <sonn...@hot.eewrote:
On Mar 28, 12:22 am, "Jeff" <j...@quixion.netwrote:
If the link that sends the user to the page with your PHP code on it
has the target as a new window (i.e <a href="download.php"
target="_blank">) then the new window will open and you will see the
dialog box in front of a empty window (i.e the white you are seeing).
If you make the link stay within the same browser window (i.e <a
href="download.php"with no target) then it should just open the
dialog box with the current browser window in the background.
It is because you are not sending new HTML for the current browser
window so it has no information for updating so it stays the same.
I think that is what you were looking for but if not then please
clarify a little more.

No need to. Seems like you understood it the way it is. I'll test that
later today.
And it worked. Tnanks&BR

Mar 29 '07 #4

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

Similar topics

2
by: Gordon H. | last post by:
I'm trying to email a HTML link to a HTML file attached in the same message. I DO NOT want to have the attached HTML file displayed in the message, I just want a link in the email to the HTML file...
1
by: Mike | last post by:
How can I provide a dialog box for a user to select a local file attachment (with just the path to the file stored as a text string in the field in my db). Is there an ActiveX control I should...
1
by: Kapil | last post by:
Hi All can u tell me how to save dynamically generated file in asp.net. like save file dialog in asp.net. kapil
6
by: Mike | last post by:
can i open the save file dialog box from a asp.net web page? thx
4
by: Jonny | last post by:
Hello Group How do I open a Save File Dialog from an ASPX page behind a browse button? Any help would be fantastic!! I am using ASP.NET 1.1 using VB.NET as the coding language TIA
0
by: Khalid | last post by:
hi, i have a web services that return me a message soap with a file attachment encoded in DIME format and sent over SOAP. This file is a PDF. I want to consume this web service with a PHP client...
9
by: deepaks85 | last post by:
Dear Sir, I have created a simple request form which will be mailed to me. Now I want to attach files and send it through that request form. For this I am using the following script: ...
1
by: =?Utf-8?B?UmFqdSBB?= | last post by:
hi, Can any one help me .. how to save outlook attachment file in C# windows Application... i m able to read the filename but i dont know how to save the attachment file to my local Drives......
1
by: martinmiksovsky | last post by:
Please could you advice me: I need to allow my access to save email attachment from Microsoft Outlook on specific from mail address and subject. Thanks a lot Martin
2
by: faiz03l | last post by:
My program can catch the attachment of email but I don't know how to save the attachment(download attachment) ? Can use the CommonDialog? or other? I need solution... Thank's
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.