I'm hacking a download management system for my site, and and working on the section to obfuscate the original file location and send a chosen file directly to a user's browser. (the files are not actually in a web viewable directory though). I have the script working so when a user calls a link, the script outputs directly to the browser. However, at the moment I store the full file location in $file (ie mysql query might end up resulting in.. $file = /home/username/downloads/test.mp3) however I still have an issue i want to resolve....
header("Content-Disposition: attachment; filename=\"$file\"");
as the filename will still *look like* the files location, when is just poor practice regardless of implications. So I've looked into using trim() and ltrim() to trim all characters before the last "/" from the string, and store that in $filename to output in the headers. No such luck so far.
Anyone have any idea if/how can i do this? Thanks
How to trim file location for download script?
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
the trim functions are not helpful for this.. basename()