View Single Post
  #3 (permalink)  
Old 03-26-2008, 11:51 PM
orjan's Avatar   
orjan orjan is offline
Learning Programmer
 
Join Date: Sep 2007
Location: Sunne, Värmland, Sweden
Age: 33
Posts: 98
Rep Power: 5
orjan will become famous soon enoughorjan will become famous soon enough
Default Re: file system based references

The most important thing is to escape the backslashes when you store the path to the database.

about substituting paths, you should url-encode your paths and filenames
but then there is the question if it's better to encode it to the db or when presenting it to the user. it depends on how you will treat the filepaths later in your code.

i hope for your security reasons that you don't think about doing like this:

"download.php?file=c:\wamp\docs\marketing\peeps\ol d\file.mp3"

but instead "download.php?fileid=23" where 23 is the id in your database reffering to the file, as in the first case, someone could rewrite the address to "download.php?file=c:\my\secret\files\passwords.tx t" and get whatever file they want from the server.
Reply With Quote