Forum Moderators: coopster

Message Too Old, No Replies

encoding urls for file names / base64 without slashes?

         

formasfunction

5:25 am on Jan 14, 2008 (gmt 0)

10+ Year Member



I'm looking for a way to tie certain file names to the url from which they originate. I wanted to use base64 encoding of the URL as the file name but it includes '/' and '=' characters which don't play well with browsers or file systems. Is there an alternative within PHP that sticks to a 0-9 A-Z a-z character set?

mikesmith76

8:50 am on Jan 14, 2008 (gmt 0)

10+ Year Member



How about hashing the url with [php.net...]

formasfunction

7:40 pm on Jan 14, 2008 (gmt 0)

10+ Year Member



I thought about using MD5 because it's exactly the sort of string result I need but I'd like to be able to derive the URL from the file name if need be and MD5 doesn't allow for that. Also, it seems like a lot of processing overhead (en masse) for something that doesn't need to be secure. Any other thoughts?

eelixduppy

5:09 pm on Jan 15, 2008 (gmt 0)



So you just want something to obscure the filename but with no security involved? Something easily undoable? How about str_rot13 [php.net] or something similar?

formasfunction

6:28 pm on Jan 15, 2008 (gmt 0)

10+ Year Member



I don't actually want to obscure it at all, I just want to guarantee that the name of the file is tied directly to the URL from which it originated, making sure there are no illegal file name characters; I don't want to lose any info in the translation.

eelixduppy

6:44 pm on Jan 15, 2008 (gmt 0)



I see now. Why don't you just use rawurlencode [us2.php.net] and it's decoding function on the filename to add into the uri. that should work as you want.