Avoid the actual path to appear

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
seema
Forum Newbie
Posts: 1
Joined: Mon Jul 31, 2006 12:09 am

Avoid the actual path to appear

Post by seema »

Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi, when i want to view/download the file the actual path appears at the url , how can i avoid this.

below is the code that i'm using

Code: Select all

if (file_exists($file_path_csv)) {

		if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)
		{
			header("Location: ".$file_path_csv);
		}
		else
		{

			$len = filesize($file_path_csv);
			header("Content-Description: File Transfer");
			header('Content-type: application/octet-stream');
			header('Content-Disposition: attachment; filename="'.$list.'"');
			header("Content-Transfer-Encoding: binary");
			header("Content-Length: ".$len);
			readfile(''.$file_path_csv.'');
		}

	}

Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You could try mod_rewrite to hide your visible URLs.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Instead of using $file_path_csv you could use md5($file_path_csv) but in that case you'd better have LUT (look up table) that contains all the pairs of paths and checksums... Or you write your own mapping mechanism...
Post Reply