AnsweredAssumed Answered

file upload using rest

Question asked by ayubalfresco on Nov 25, 2014
Hi I am trying to upload file using REST. Below is the code of html page which I have deployed on tomcat. I am able to upload file, however the response appears to be downloaded and none of the call back methods are being invoked. Could some one assist me ?

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "">
    <script src="http://localhost:9090/SharePortlet/js/jquery-1.7.1.js"></script>
    <script src="http://localhost:9090/SharePortlet/js/jquery.form.js"></script>
     (function() {
                    dataType:  'json',
                    success:   processJson,
                    complete: function(xhr) {
               $(document).ajaxSuccess(function (evt, jqXHR, settings) {
                      alert("Global success callback.");
                    $(document).ajaxError(function (evt, jqXHR, settings, err) {
                      alert("Global error callback.");
     function processJson(data) {
                // 'data' is the json object returned from the server
    <div id="status"></div>
    <table style="width: 100%;" cellpadding="0" cellspacing="0">
               <tr style="height: 100%;" valign="top">
    <iframe name="hiddenIframe" id="hiddenIframe" style="display: none;" ></iframe>
            <form target="hiddenIframe" style="margin: 0px 10px 0px 10px" id="uplForm" enctype="multipart/form-data" method="post" action="http://localhost:8080/alfresco/service/api/upload">
    <input type="hidden" name="destination" id="destination" value="workspace://SpacesStore/8bb36efb-c26d-4d2b-9199-ab6922f53c28"/>
            <input type="text" name="filename" id="filename"/><p/>
            <textarea name="description" id="description"></textarea>
                                <div style="margin-bottom: 20px; font-weight: bold">
                                <div style="margin-bottom: 10px;">
                                    Please upload your file here:
                                      <div style="margin-bottom:20px;">
                                    <input class="button" type="file" name="filedata" id="filedata"/>
                                    <input id="uplBtn" type="submit" value="Upload" />