473,385 Members | 1,848 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.

header() for download - pb in ns7

Hi, I have made a php page where people can configure a javascript online
with a preview and then dowload the result. Here is the code:
<?
// Some code that create a temp file ($file handler = $fd) and write the
script

// Send the file
header("content-type: text/plain");
header("Content-length: ".filesize($file));
header('Content-Disposition: attachment; filename="script_name.js"');
flush();
while(!feof($fd)){
echo fread($fd, 1024);
flush();
}
fclose($fd);
?>

Everything works fine with IE, Mozilla, FireFox and Opera. But with Netscape
(7.0) no file is sent and I end up with a blank page. But still with
Netscape, if I right-click the link and choose save as..., then it works ok
Any idea ?

Thanks
Dae
Jul 17 '05 #1
7 1861
Looks like Netscape (at least 7.0) don't want to download text/plain even
with attachment specified.

Hi, I have made a php page where people can configure a javascript online
with a preview and then dowload the result. Here is the code:
<?
// Some code that create a temp file ($file handler = $fd) and write the
script

// Send the file
header("content-type: text/plain");
header("Content-length: ".filesize($file));
header('Content-Disposition: attachment; filename="script_name.js"');
flush();
while(!feof($fd)){
echo fread($fd, 1024);
flush();
}
fclose($fd);
?>

Everything works fine with IE, Mozilla, FireFox and Opera. But with Netscape (7.0) no file is sent and I end up with a blank page. But still with
Netscape, if I right-click the link and choose save as..., then it works ok Any idea ?

Thanks
Dae

Jul 17 '05 #2
Have you tried specifying different MIME type? Eg. "text/javascript" ?

Hilarion
Jul 17 '05 #3

"Hilarion" <hi******@SPAM.op.SMIECI.pl> wrote in message
news:cn**********@news.onet.pl...
Have you tried specifying different MIME type? Eg. "text/javascript" ?


Yes I tried. But actually I already solved my problem, I just forgot to post
my solution here;
So "text/plain", "text/javascript" and "application/x-javascript" behave the
same way: printing the content of the file in the browser (Netscape 7).
I finally used "application/octet-stream" to force NS to download it. Only
problem is that without some setting changes NS always try to save the file
as script_name.js.php. Anyway most people will just remove the php extension
and even if they don't the script will work with the php extension.

Dae
Jul 17 '05 #4
"Daedalus" <ar**************@videotron.ca> wrote in message news:<30*************@uni-berlin.de>...
"Hilarion" <hi******@SPAM.op.SMIECI.pl> wrote in message
news:cn**********@news.onet.pl...
Have you tried specifying different MIME type? Eg. "text/javascript" ?


Yes I tried. But actually I already solved my problem, I just forgot to post
my solution here;
So "text/plain", "text/javascript" and "application/x-javascript" behave the
same way: printing the content of the file in the browser (Netscape 7).
I finally used "application/octet-stream" to force NS to download it. Only
problem is that without some setting changes NS always try to save the file
as script_name.js.php. Anyway most people will just remove the php extension
and even if they don't the script will work with the php extension.


You may want to look at the usernotes section of
<http://in2.php.net/header> Each browser requires different headers.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com
Jul 17 '05 #5
> You may want to look at the usernotes section of
<http://in2.php.net/header> Each browser requires different headers.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com


Yes I've already look there (including the user notes). And AFAIK browsers
do not really require different headers, but they may behave differently
with some headers (mostly the non HTTP1.1 standard headers like
Content-Disposition). This is "AFAIK". Anyone, feel free to correct me.

Dae
Jul 17 '05 #6
Daedalus wrote:
Hi, I have made a php page where people can configure a javascript online
with a preview and then dowload the result.
Everything works fine with IE, Mozilla, FireFox and Opera. But with Netscape
(7.0) no file is sent and I end up with a blank page. But still with
Netscape, if I right-click the link and choose save as..., then it works ok


I guess it has to do whit some content-type detections in netscape (based on
mozilla 1.0.1 if I remeber it right), I would make a browser type check and if
it detects netscape 7.0, then use another content-type, this is how things
like this are usually solved in MSIE when it don't want to work.
//Aho
Jul 17 '05 #7
"Daedalus" <ar**************@videotron.ca> wrote in message news:<30*************@uni-berlin.de>...
You may want to look at the usernotes section of
<http://in2.php.net/header> Each browser requires different headers.


Yes I've already look there (including the user notes). And AFAIK browsers
do not really require different headers, but they may behave differently
with some headers (mostly the non HTTP1.1 standard headers like
Content-Disposition). This is "AFAIK". Anyone, feel free to correct me.


Sorry, didn't mean all the headers; but to force download...
<http://in.php.net/header#21708> and
<http://cvs.sourceforge.net/viewcvs.py/phpmyadmin/phpMyAdmin/export.php?rev=2.17&view=markup>
(search for "// Download").

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com
Jul 17 '05 #8

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

Similar topics

2
by: Thomas Kemmerich | last post by:
hi, i'm looking for a possibility to start a download. here is my current code: header("Content-Type: $_contenttype"); header("Content-Disposition: attachment; filename=\"$_filename\"");...
18
by: Frank Thorstens | last post by:
Hi, i try to give my script headers so the output text would be downloaded in the client's browser and not displayed. But it doesn't work at all in my IE 6 and Opera. <?...
1
by: surfspider | last post by:
Hi, I have a little problem with the header function. I have a few links to pdf files on eshop.php. The links are like this : download.php?pdfid=1 In download.php I get the filename from the...
1
by: mr_burns | last post by:
hi, i have been tryin to prompt the download of a file on the server using the following code: // send headers, forcing download: header("Content-type: application/word");...
5
by: mr_burns | last post by:
hi, i am trying to create code that will prompt the user to download. below is the code i am using: .. .. ..
1
by: Inpreet | last post by:
Hello I am using: ************************************************************************* header("Content-Type:application/force-download",false); header("Content-Disposition: attachment;...
1
by: Mich Romney & De Shriners | last post by:
I have created an MP3 download app from mysql. It plays the song fine. :) Only problem is that when it downloads, all the header information, like song lyrics, credits and album cover have all...
6
ak1dnar
by: ak1dnar | last post by:
Hi, I am creating script to download some files using download dialog box.First time i tried to use ajax for this, but i failed. So i went through this way, By Using this function i am going to...
2
by: smartic | last post by:
i'm having problem with session_start() to force the browser to download file with this function: session_start(); function force_download($file){ if ((isset($file))&&(file_exists($file)))...
8
by: JRough | last post by:
What is the purpose of caching in the header below? I used something like this for downloading a detail page to Excel but in this example it looks like it is for cache control? Why would you...
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:
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...
0
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,...
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,...

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.