471,887 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,887 software developers and data experts.

Prevent file execution when opened in browser


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.

Oct 21 '08 #1
2 1195
16,027 Expert Mod 8TB
You can't do this with JavaScript. Keep the file out of the web root.
Oct 21 '08 #2
392 Expert 256MB
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.

Similar topics

4 posts views Thread by Frank | last post: by
1 post views Thread by hotice3100 | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.