You may need to escape the quotes for the readfile:
I'd still try just using urlencode($file) for the content-type header(), though, since that's an HTTP issue, not a local file system issue. But as others have said, I'd personally really try to avoid using any questionable characters in the first place.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
I perfectly know that leaving "dangerous" characters in uploaded files is a bad practise, but we're talking about MP3 songs...
You know, there's TAGS inside MP3, so when the file is injected into an iPod, it reads correctly the song name independently by the filename. But we all know that many times users prefer to archive mp3 files with their real name in personal hard disk archives (nothing's dangerous in that case), and it's simply more comfortable to have the ready thing.
Then i know, the best solution is to rename MP3 files and delete the single quotes before upload them in FTP... and i think finally will be the right way, even if we're talking about thousands songs (i'll use a file renamer software for a massive rename operation)!
So consider this thread just as a highliting about URL management
Last edited by MrSnowDrop; 04-07-2011 at 02:18 AM.
and since the files are hosted on your own server, I agree with the others that you shouldnt make bad names and maybe create alliases for filenames in the database and clean file names in the file itself
Won't windows clients reject files with quotes of any kind anyway? (or is that just double-quotes?)
I cannot assign and/or upload "double-quotes" in filenames; but it's technically possibile to insert a single quote and upload it.
Anyway, i'll proceed to convert/rename my MP3 files in order to remove quotes... i already have tried things like replace %27 instead of a single quote, but the problem seems to persist in php string interpretation, because finally the uploaded file doesn't match.
The main page with the anchors is written in HTML/VBSCRIPT and anchors are looped and linked to MP3s through a Database which will help users to obtain full and correct informations in the site.
It was only a clarification about php and url strings, around a script download specific context.
Thank you very much people!
Last edited by MrSnowDrop; 04-07-2011 at 09:14 AM.