Sending "virtual" files with php? Possible?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lolife
Forum Newbie
Posts: 3
Joined: Tue Jan 18, 2005 12:45 pm

Sending "virtual" files with php? Possible?

Post by lolife »

Is there any way to send the browser a sort of virtual file that php is generating on-the-fly? In my case, it's a winamp playlist. I don't want to go through the hassle of creating files and then see to it that they are deleted properly, etc, etc. :wink:
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Instead of fwriting it to a file, just echo it (so it's recieved by the client).

perhaps you need to lookup the right mimetype... and output that with the header function..
lolife
Forum Newbie
Posts: 3
Joined: Tue Jan 18, 2005 12:45 pm

Post by lolife »

Well.. How will php know to parse the file if it's called .m3u, as winamp playlists are supposed to? The browser is supposed to know to open it with winamp. Could be I misunderstood you, though, so please elaborate a bit. I'm no guru at this :wink: .
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you can tell the browser, the output of php is any file type. read the header() function documentation for how that's accomplished. With header() you can also tell the browser what filename to create, if the user chooses to save the file.
lolife
Forum Newbie
Posts: 3
Joined: Tue Jan 18, 2005 12:45 pm

Post by lolife »

Yup, I see now. Eureka kind of. :wink:

Thanks a lot to both of you!
Post Reply