jonybhi Posted December 11, 2007 Share Posted December 11, 2007 Hello, I want to design a page where my members enter private code to download a file. and the file cannot be downloaded without entring correct code. and also search engines does not show that page as search result. Thanks Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 11, 2007 Share Posted December 11, 2007 you need to set-up a user login that allows the only your member to access the download file. Quote Link to comment Share on other sites More sharing options...
jonybhi Posted December 11, 2007 Author Share Posted December 11, 2007 if a person knows the direct link then he can download file. Quote Link to comment Share on other sites More sharing options...
beansandsausages Posted December 11, 2007 Share Posted December 11, 2007 well whats the point in making it private ?? when all you can do is this http://www.yoursite.com/index.php?link=private or sumit like that to acssess the file then any 1 could do it. its not that secure so like PhPQuestioner said your best making a login Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 11, 2007 Share Posted December 11, 2007 you could create a dynamic url based on user login session - do some searching about how to prevent hot linking. Quote Link to comment Share on other sites More sharing options...
jonybhi Posted December 11, 2007 Author Share Posted December 11, 2007 Now I used .htaccess and stopped hot linking but now How could my users will download that by entring a simple code. Please provide me the source Code. Quote Link to comment Share on other sites More sharing options...
beansandsausages Posted December 11, 2007 Share Posted December 11, 2007 a simple code for what ? to down load the file ? Quote Link to comment Share on other sites More sharing options...
jonybhi Posted December 11, 2007 Author Share Posted December 11, 2007 yes. Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 11, 2007 Share Posted December 11, 2007 here is a script that I use for a pdf file download: <?php $file="myfile.pdf" // add file's url to this variable header("Content-type: application/force-download"); header('Content-Disposition: inline; filename="' .$file . '"'); header("Content-Transfer-Encoding: Binary"); header("Content-length: ".filesize($file)); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . $file . '"'); readfile("$file"); ?> you will need to validate member before allowing them to access this script. Quote Link to comment Share on other sites More sharing options...
beansandsausages Posted December 11, 2007 Share Posted December 11, 2007 haha you beat me and your code a bit more neat haha Quote Link to comment Share on other sites More sharing options...
jonybhi Posted December 11, 2007 Author Share Posted December 11, 2007 hay thanks for the code. but It didn't work. I copied the whole code and made a file get.php and renamed myfile.pdf to my original file. but I gives blank page. Quote Link to comment Share on other sites More sharing options...
beansandsausages Posted December 11, 2007 Share Posted December 11, 2007 well whats the name for the pdf file ? or the file want downloading Quote Link to comment Share on other sites More sharing options...
jonybhi Posted December 11, 2007 Author Share Posted December 11, 2007 I have a rar file. and its name is control.rar I just pasted the code and saved it as php. Should i write some more code like <html> or else? Quote Link to comment Share on other sites More sharing options...
beansandsausages Posted December 11, 2007 Share Posted December 11, 2007 the easiert way to download some thing is set a link <a href=\"mysite.com/downalodfile.extension\"> download </a> but then any tom dick or harry could download it if they knew the link. THAT IS NOT A SECURE WAY TO DO IT. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.