php_joe Posted April 5, 2008 Share Posted April 5, 2008 I have a JavaScript code on an external file that I'd like to keep private. I know that I can use htaccess to block direct access to the folder, but: 1. Will that prevent them from saving the file using "Save As"? 2. Will that prevent the index page from calling it as an external javascript file? Is there any additional methods that I can use to prevent people from viewing or saving an external javascript file? Thanks in advance, Joe Quote Link to comment https://forums.phpfreaks.com/topic/99655-preventing-detecting-direct-access-to-a-file/ Share on other sites More sharing options...
benjaminbeazy Posted April 5, 2008 Share Posted April 5, 2008 yes it will prevent the script from being able to call it.. u cant keep javascript private because it is client-side. the browser must have js enabled and be able to interpret it.... you can make it rather obscure if u really want to. best bet is not to put anything in js that you dont want ppl to see. Quote Link to comment https://forums.phpfreaks.com/topic/99655-preventing-detecting-direct-access-to-a-file/#findComment-509795 Share on other sites More sharing options...
php_joe Posted April 5, 2008 Author Share Posted April 5, 2008 I was hoping there was a way in PHP to detect if a file was being accessed directly or was being called from another page on my server. I was also hoping that there was a way to prevent people from using "Save As" to download it. Quote Link to comment https://forums.phpfreaks.com/topic/99655-preventing-detecting-direct-access-to-a-file/#findComment-509798 Share on other sites More sharing options...
benjaminbeazy Posted April 5, 2008 Share Posted April 5, 2008 doesn't make a difference though really. javascript is client-side. no matter how you slice, the user can see javascript. whether its a different file or directly on the page. Quote Link to comment https://forums.phpfreaks.com/topic/99655-preventing-detecting-direct-access-to-a-file/#findComment-509799 Share on other sites More sharing options...
benjaminbeazy Posted April 5, 2008 Share Posted April 5, 2008 there are methods you could use, but they are rather complex to try and accomplish this... Quote Link to comment https://forums.phpfreaks.com/topic/99655-preventing-detecting-direct-access-to-a-file/#findComment-509801 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.