Page 1 of 1
Sending "virtual" files with php? Possible?
Posted: Thu Jan 20, 2005 5:33 pm
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.

Posted: Thu Jan 20, 2005 5:39 pm
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..
Posted: Thu Jan 20, 2005 5:54 pm
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

.
Posted: Thu Jan 20, 2005 6:03 pm
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.
Posted: Thu Jan 20, 2005 10:22 pm
by lolife
Yup, I see now. Eureka kind of.
Thanks a lot to both of you!