0

My requirement is to develop the file upload functionality using Ajax request. The only condition is that my application works with only IE7. So I cannot use Jquery FormData using which I can submit the form values. I am currently using the following piece of code for my file upload functionality. But it is not working. Can anybody share the code by which I can upload a file and send form data in IE7?

<form id="CreateAttachmentForm" method="post"  enctype="multipart/form-data"  action="../../uploadFile" >



<input type="file" id="fileupload1" name="fileupload1" accept="image/*,application/pdf"    "/>


<contact:contactbutton
                            id="printButton"
                            style="position:relative; width:90px; top:27px; height:30px; left:160px;"
                            textTop="7px"
                            defaultButton="false"
                            tabindex=""
                            accesskey="C"
                            onClick="return createAttachmentRequest(this.form, this.fileupload1 );"
                            onfocus="if(event.altKey){click();}">
                                <u>C</u>reate
                 </contact:contactbutton>

function createAttachmentRequest(form,fileupload1){
              att=form.action;
    $.post(att, {fileupload1: fileupload1.value}).done(function(data){
    });
    return true;
Ashok.N
  • 1,327
  • 9
  • 29
  • 64
  • It isn't supported by older versions of IE. There are quite a few examples and discussions online about how to get round it: https://www.google.co.uk/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=IE7+ajax+file+upload I'm not going to recommend one because I've no direct experience of any of them. I feel sorry for you still developing for IE7. Whoever your customer is, running such outdated technology, should be ashamed of themselves for not upgrading after all this time. – ADyson Apr 18 '17 at 13:01
  • @ADyson, Thanks for the response. I was in the impression that the application can run in IE11, but after your suggestion as part of another question(http://stackoverflow.com/questions/43372855/jquery-success-function-is-not-called-after-executing-the-rest-url), I have cross checked and realized that the browser is running in compatibility mode for IE7. So, my struggles started again.. :( – Ashok.N Apr 18 '17 at 13:04
  • are you allowed to ditch the compatibility mode? That would be the simplest solution, assuming it will work for the end-users. – ADyson Apr 18 '17 at 13:08
  • I have already verified that it's not working in IE11 after I remove the compatibility mode. So, it would be a big task if the application has to support IE11. – Ashok.N Apr 18 '17 at 13:12
  • Yuk, you don't want a whole re-write of the UI I guess just to solve this (although it's long overdue in general, if it only works properly in 7). I suggest you re-implement the upload stuff using the suggestions in that Google search I linked to above. If you want to support more modern methods simultaneously you could use conditional comments to allow the browser to choose which version of the code to run based on the IE version (other non-IE browsers will ignore conditional comments and just run whatever is not commented out). – ADyson Apr 18 '17 at 13:24

0 Answers0