By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,831 Members | 1,031 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,831 IT Pros & Developers. It's quick & easy.

Prevent file execution when opened in browser

P: 4
Hi,

I have a requirement in which I have Prevent code from being executed when opened in browser. To put it in simple words, consider the following scenario
I have a locale.properties file present in webserver.
if i tries to open this file from browser, instead of displaying the content, it should popup a dialog-box asking user to open/save/cancel.

Any help in this regard will be appreciated. Let me know if my requirement is not clear.


Thanks
sunny
Oct 21 '08 #1
Share this Question
Share on Google+
2 Replies


acoder
Expert Mod 15k+
P: 16,027
You can't do this with JavaScript. Keep the file out of the web root.
Oct 21 '08 #2

Expert 100+
P: 392
I properties file is not executable. It is just plain text, it can only be displayed.

If you want to force a save file dialog box you will need to change the response MIME type to an invalid value. Something like "application/unknown" or "app/download". That is not something you do with JavaScript. You would need to change the server configuration, or use server side code.
Oct 21 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.