473,800 Members | 2,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Headers for streaming files

Hi

I know this question is rather HTTP related than PHP, but I did not find an
HTTP group on my news server.

I deliver some files with the following PHP syntax:

header('Content-Description: File Transfer');
header('Content-Type: '.$mimetype);
header('Content-Length: '.filesize($fil e));
header('Content-Disposition: attachment; filename='.$fil ename);
readfile($file) ;

That works well with file types that need to be downloaded to disk. Anyway
if the file is a MP3 file, both IE and Mozilla do the same, they prompt me
to decide if I want to save it to disk, and then download the file entirely
before opening a player.

I sniffed for the differences in headers when a normal link to an mp3 file
is clicked and both tested UAs start streaming and playing immediately:
There is no Content-Disposition header. Removing this header, or just the
"attachment " part of it, results in the expected streaming behaviour, but
the filename is lost, and the script's filename is used instead.

Is it possible to serve the filename without a Content-Disposition header?
Or is there an alternative to the value "attachment ", which still allows me
to deliver a filename?

Thanks for a hint
Markus
Jul 17 '05 #1
7 5450
Markus Ernst <derernst@no#sp #amgmx.ch> wrote:
There is no Content-Disposition header. Removing this header, or just the
"attachment " part of it, results in the expected streaming behaviour, but
the filename is lost, and the script's filename is used instead.

Is it possible to serve the filename without a Content-Disposition header?
Or is there an alternative to the value "attachment ", which still allows me
to deliver a filename?


What about generating URL with the desired filename? There are a couple
of ways to do this (depending on webserver) but easiest is propably with
(apache) MultiViews:
/foo/stream/filename
where stream.php is in the dir foo. The script can retrieve filename
from $_SERVER['PATHINFO'] (IIRC).

The rewrite engine is another easy solution.

--

Daniel Tryba

Jul 17 '05 #2
"Markus Ernst" <derernst@NO#SP #AMgmx.ch> wrote in message news:<41******* *************** *@news.easynet. ch>...
Hi

I know this question is rather HTTP related than PHP, but I did not find an
HTTP group on my news server.

I deliver some files with the following PHP syntax:

header('Content-Description: File Transfer');
header('Content-Type: '.$mimetype);
header('Content-Length: '.filesize($fil e));
header('Content-Disposition: attachment; filename='.$fil ename);
readfile($file) ;

That works well with file types that need to be downloaded to disk. Anyway
if the file is a MP3 file, both IE and Mozilla do the same, they prompt me
to decide if I want to save it to disk, and then download the file entirely
before opening a player.

I sniffed for the differences in headers when a normal link to an mp3 file
is clicked and both tested UAs start streaming and playing immediately:
There is no Content-Disposition header. Removing this header, or just the
"attachment " part of it, results in the expected streaming behaviour, but
the filename is lost, and the script's filename is used instead.


Try "Content-Disposition: inline; filename=$filen ame".
Jul 17 '05 #3
Chung Leong wrote:
"Markus Ernst" <derernst@NO#SP #AMgmx.ch> wrote in message
news:<41******* *************** *@news.easynet. ch>...
Hi

I know this question is rather HTTP related than PHP, but I did not
find an HTTP group on my news server.

I deliver some files with the following PHP syntax:

header('Content-Description: File Transfer');
header('Content-Type: '.$mimetype);
header('Content-Length: '.filesize($fil e));
header('Content-Disposition: attachment; filename='.$fil ename);
readfile($file) ;

That works well with file types that need to be downloaded to disk.
Anyway if the file is a MP3 file, both IE and Mozilla do the same,
they prompt me to decide if I want to save it to disk, and then
download the file entirely before opening a player.

I sniffed for the differences in headers when a normal link to an
mp3 file is clicked and both tested UAs start streaming and playing
immediately: There is no Content-Disposition header. Removing this
header, or just the "attachment " part of it, results in the expected
streaming behaviour, but the filename is lost, and the script's
filename is used instead.


Try "Content-Disposition: inline; filename=$filen ame".


Thank you Chung. I tried this, but it did not help as the filename only
seems to have an effect with the attachment setting.

--
Markus
Jul 17 '05 #4
Daniel Tryba wrote:
Markus Ernst <derernst@no#sp #amgmx.ch> wrote:
There is no Content-Disposition header. Removing this header, or
just the "attachment " part of it, results in the expected streaming
behaviour, but the filename is lost, and the script's filename is
used instead.

Is it possible to serve the filename without a Content-Disposition
header? Or is there an alternative to the value "attachment ", which
still allows me to deliver a filename?


What about generating URL with the desired filename? There are a
couple of ways to do this (depending on webserver) but easiest is
propably with (apache) MultiViews:
/foo/stream/filename
where stream.php is in the dir foo. The script can retrieve filename
from $_SERVER['PATHINFO'] (IIRC).

The rewrite engine is another easy solution.


Thank you Daniel. I was not aware of MultiViews and will read more on this
interesting possibility. I thought about using the rewrite engine before; I
use it for creating search-engine friendly urls already. Anyway I am not too
familiar with using .htaccess and also don't want to rely on it too much for
non-optional stuff, as the application must be installable on servers with
various configurations.

I think what I will do is actually re-write the application and store the
files with their actual filenames (and validate these on upload), instead of
storing them with custom names and giving the filename back on download, as
I tried. So I won't have to handle the headers at all, as I can simply link
the files.

--
Markus
Jul 17 '05 #5
.oO(Markus Ernst)
I sniffed for the differences in headers when a normal link to an mp3 file
is clicked and both tested UAs start streaming and playing immediately:
There is no Content-Disposition header. Removing this header, or just the
"attachment " part of it, results in the expected streaming behaviour, but
the filename is lost, and the script's filename is used instead.


For streaming MP3s there's another way:

http://www.developingwebs.net/html/mp3.php

Micha
Jul 17 '05 #6
Michael Fesser wrote:

For streaming MP3s there's another way:

http://www.developingwebs.net/html/mp3.php


Thank you for pointing me to this interesting tutorial. This method looks
similar to what you have to do with RealAudio files. Do you know what is the
advantage of using an intermediate text file which points to the audio
source?

--
Markus
Jul 17 '05 #7
.oO(Markus Ernst)
Michael Fesser wrote:

For streaming MP3s there's another way:

http://www.developingwebs.net/html/mp3.php

Thank you for pointing me to this interesting tutorial. This method looks
similar to what you have to do with RealAudio files. Do you know what is the
advantage of using an intermediate text file which points to the audio
source?


The browser only downloads the little text file with the resource
pointer, the download of the media file is handled directly by the
associated application, which will take care of the streaming and maybe
other things (buffering for example).

If you link directly to the media file instead the browser will probably
download it first, before handing over to the player.

Micha
Jul 17 '05 #8

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

Similar topics

3
2344
by: A.M-SG | last post by:
Hi, I have a ASP.NET aspx file that needs to pass large images from a network storage to client browser. The requirement is that users cannot have access to the network share. The aspx file must be the only method that users receive image files.
1
1405
by: adiela | last post by:
hello everyone..i would like to ask something regarding my project.. i've been planning to develop a website using asp code for streaming multimedia features...unfortunatly...i have zero knowledge bout all this things that needed...can someone give me a rough guideline bout what should i do step-by-step... such as..what database should i use...how can i store or create a database that can hold my multimedia files? i really do need ur...
5
3252
by: Manuel Alves | last post by:
Hi, Is it possible to store media files (like windows .wmv) on SQL Server 2005 and stream it back to the client via media server (not just download it)? Regards, Manuel Alves
0
1016
by: siddhath | last post by:
Hi all, When I try to open a .pdf file. browser throws a error that pdf file is nt cached. Site has no cache headers applied and SSL is enable. I think this is the reason for that to happen. http://support.microsoft.com/?id=316431
0
1081
by: siddharthkhare | last post by:
Hi all, When I try to open a .pdf file. browser throws a error that pdf file is nt cached. Site has no cache headers applied and SSL is enable. I think this is the reason for that to happen. http://support.microsoft.com/?id=316431
2
1955
by: Cerebral Believer | last post by:
Hi All, I plan to use streaming audio on my site. I had uploaded some .mp3's as part of a trial, and these streamed very badly so I tried .ram (RealAudio) files instead. The RealAudio files are a lot smaller in size, but they do not stream, a user has to download the file before listening to it. Which format would you recommend for good to high quality audio streaming? Should RealAudio files stream? If so how can I get them to...
8
7676
by: poorna | last post by:
hi all i want to upload the video files to the server.. then i encode all the video files into flv files ... and then i am go to streaming ... in the mean while i create the thumbnail image from video.. doubts: how to upload the video files to web server?
8
65839
by: Amjad | last post by:
Hi i am writing a application where i want to browse video file and copy data into stream and send that stream over network...I have develop P2P windows application where i successfully transfer text message to each other but now i want to send video file and play that file on other end...I know the code how to send the stream over the network but basic problem is how open that file as a stream. Thanks
3
4047
by: Brad | last post by:
I have an aspx page that is sending pdf files to client browsers: it uses a filestream to read the pdf file and response.binarywrite to send content to the browser. This has worked great for years in IE, Firefox and Opera on windows, and it works on a Mac with Firefox and Opera. But this fails in Safari with the generic message "A network error occurred while accessing this document". Here is a link to try out ...
0
9691
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
10279
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
10255
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
10036
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
9092
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...
1
7582
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.