Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
16
rated 0 times [  20] [ 4]  / answers: 1 / hits: 18552  / 11 Years ago, wed, march 27, 2013, 12:00:00

Relating to my last question. I have an upload field where the user can choose a picture and this becomes resized (client-side via JavaScript), base64 encoded (JavaScript as well) and sent via a hidden field. I do this in order to save bandwidth of the user (e.g. usage with a 3G connection).



But I don't know how to not send the user upload file <input type=file name=file id=file class=span4> within the <form> tags. The obvious solution would be to exclude the file upload field from the form but this would kill my layout. Is this possible?


More From » jquery

 Answers
13

You can do the following with jQuery to disable your input field:



$('#file').prop('disabled', true);


Altogether you might have this:



// domReady handler
$(function() {

// provide an event for when the form is submitted
$('#myform').submit(function() {

// Find the input with id file in the context of
// the form (hence the second this parameter) and
// set it to be disabled
$('#file', this).prop('disabled', true);

// return true to allow the form to submit
return true;
});
});

[#79287] Wednesday, March 27, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alanisannettep

Total Points: 695
Total Questions: 96
Total Answers: 91

Location: Australia
Member since Sat, May 27, 2023
1 Year ago
;