XeroXer Posted December 27, 2006 Share Posted December 27, 2006 Hi there!I am making a download directory that demands that the user is logged in.Got any idea on how to either randomize a download link for every user download or to make the exact file link never show.Really need help with this and I haven't found a good system for this yet. Link to comment https://forums.phpfreaks.com/topic/31988-solved-randomunique-download-link/ Share on other sites More sharing options...
onlyican Posted December 27, 2006 Share Posted December 27, 2006 You can rewrite links in php[code]<?phpfunction send_file($path, $display){ if (!is_file($path) or connection_status()!=0) return(FALSE); header("Content-type: unknown/unknown"); header("Content-Disposition: attachment; filename=\"$display\""); header("Pragma: public"); header("Cache-control: private"); header("Content-transfer-encoding: binary\n"); header("Content-length: ".(string)(filesize($path))); header("Expires: 0"); header("Pragma: no-cache"); if ($file = fopen($path, 'rb')) { while(!feof($file) and (connection_status()==0)) { print(fread($file, 1024*300)); flush(); } $status = (connection_status()==0); fclose($file); } return($status);}$requested_file = (( isset($_GET['file']) )?($_GET['file']): (''));// Fake filename => Real Filename$rewrite = array('Example.rar'=>'test/myrar.rar','Tutorial.zip'=>'x401TPT.zip');if(array_key_exists($requested_file,$rewrite)){ send_file($rewrite[$requested_file],$requested_file);} ?>[/code]You can call this withwww.example.com/page.php?file=Example.rarand Example.rar will downloadBut the file is in a folder called test, and the file is called myrar.rarWith a Little playing, you can do it different ways Link to comment https://forums.phpfreaks.com/topic/31988-solved-randomunique-download-link/#findComment-148515 Share on other sites More sharing options...
XeroXer Posted December 27, 2006 Author Share Posted December 27, 2006 OMG you rock.That was the best solution I have ever seen... :)It worked and it's just what I wanted.Thanks a lot... Link to comment https://forums.phpfreaks.com/topic/31988-solved-randomunique-download-link/#findComment-148527 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.