Anonymous
Anonymous

Reputation: 4632

How to lock input[type=file]?

I want to lock my input files from editing by user while I'm submitting my files in a chain (through wrappers and callbacks).

Although it was easy to lock my form just by adding readonly attributes to the input elements:

$('form input').attr('readonly','readonly');

It just doesn't work on input files.

The disabled attribute kinda works, but it wouldn't submit the file then...

So, any ideas how to lock it?

Upvotes: 1

Views: 676

Answers (2)

lynne lv
lynne lv

Reputation: 1

or you can try this:
$('input[type=file]').click(function(){
   $(this).attr('disabled', 'disabled');
});

Upvotes: -2

Ram
Ram

Reputation: 144669

You can use the preventDefault() method of the event object, try the following:

$('input[type=file]').click(function(e){
   e.preventDefault()
})

http://jsfiddle.net/LvXJJ/

Upvotes: 4

Related Questions