Naming file on server depending upon download request
Posted: Sat Sep 05, 2009 6:02 am
I need to create a folder on root of my website server, called 'Docs'. In this folder I want to keep hello.doc file. Now I want this file to be downloaded even if user provides an incorrect file name (as far as the user's path fall under 'Docs' folder):
Which mean:
If someone downloads http://www.mysite.com/Docs/hello.doc He gets hello.doc downloaded.
However if someone downloads http://www.mysite.com/Docs/price.doc He gets the same file i.e. hello.doc renamed as price.doc when he downloads it.
This means I require something that renames a file depending upon the path it was given for the download. A good example of this you can see by going to http://www.newsoftwares.net/folderlock/
On this page if you click http://dl.filekicker.com/nc/file/130083 ... -lock6.exe
then a file named folder-lock6.exe will get downloaded.
If however you provide it with any other name, lets say your name is 'Mark' then you will get the same file downloaded (the same content of file) but renamed. Try it http://dl.filekicker.com/nc/file/130083-0M78/Mark.exe
I want to accomplish this for my site. Please help me understand and do it. A code snippet will be very appreciated.
Which mean:
If someone downloads http://www.mysite.com/Docs/hello.doc He gets hello.doc downloaded.
However if someone downloads http://www.mysite.com/Docs/price.doc He gets the same file i.e. hello.doc renamed as price.doc when he downloads it.
This means I require something that renames a file depending upon the path it was given for the download. A good example of this you can see by going to http://www.newsoftwares.net/folderlock/
On this page if you click http://dl.filekicker.com/nc/file/130083 ... -lock6.exe
then a file named folder-lock6.exe will get downloaded.
If however you provide it with any other name, lets say your name is 'Mark' then you will get the same file downloaded (the same content of file) but renamed. Try it http://dl.filekicker.com/nc/file/130083-0M78/Mark.exe
I want to accomplish this for my site. Please help me understand and do it. A code snippet will be very appreciated.