0

How to set jQuery ajax response as input type="file" value for updation purpose? Here I get question response as byte[] array. How do I set this to file type?

JS

$.ajax({
    type: 'POST',
    url: 'viewQuestion.html',
    data: ({
        questionId: id
    }),
    success: function(responseData) {
        $('#updateQstn').val(responseData.question);
    }
});

HTML

<input type="file" value="Browse" name="updateQstn"
        accept="image/*" id="updateQstn" />
Regent
  • 5,142
  • 3
  • 21
  • 35
boycod3
  • 5,033
  • 11
  • 58
  • 87
  • What for do you want to do this? I doubt it's possible. – Regent Sep 22 '14 at 09:14
  • for updation purpose i want to set value to this conrol.unless i throw exception. if user update image change value to new value. i can do that. if user doesnot want to change it ,it remain same value. – boycod3 Sep 22 '14 at 09:18
  • Take a look at [this](http://stackoverflow.com/questions/1696877/how-to-set-a-value-to-a-file-input-in-html) question and [this](http://stackoverflow.com/questions/1017224/dynamically-set-value-of-a-file-input) one. Yes, they are about file URLs, but I have never heard about setting `input type="file"` value as byte array. – Regent Sep 22 '14 at 09:20
  • thnx Regent it is not possible. – boycod3 Sep 22 '14 at 09:29

0 Answers0