File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Disable right click, copy & paste option in <html:file> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Disable right click, copy & paste option in <html:file>" Watch "Disable right click, copy & paste option in <html:file>" New topic

Disable right click, copy & paste option in <html:file>

Sandeep Swaminathan
Ranch Hand

Joined: Apr 23, 2008
Posts: 52
By using onkeydown="this.blur()" I'm able to restrict the user to enter to enter the pathname manually but I'm able to copy paste the location of the file. How do I disable it so that the user is only forced to click the browse button and choose a file to upload?

Note: Browse button logic I have implemented. No probs in that >

Music is all around us. All you have to do is just LISTEN to it,
Sandeep Swaminathan
David Newton

Joined: Sep 29, 2008
Posts: 12617

Moving to HTML/JavaScript. This isn't a Struts question.
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
Just make sure you do not kill keyboard navigation, not everyone uses a mouse.

It is impossible to block all of these operations since you can not block Edit --> Paste and some others.

Some browsers do not even let you type it in anymore.

Is it too hard to put validation on the server to say hey the file did not exist when it fails?

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63852

Please read this.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Disable right click, copy & paste option in <html:file>
It's not a secret anymore!