dojo.io.iframe erroring when uploading a file

Posted by Grant Collins on Stack Overflow See other posts from Stack Overflow or by Grant Collins
Published on 2010-04-02T10:13:35Z Indexed on 2010/04/03 17:03 UTC
Read the original article Hit count: 486

Filed under:
|

Hi,

Hit an interesting problem today when trying to upload an image file < 2MB using dojo.io.iframe.

My function to process the form is called, but before the form is posted to the server I am getting the following error:

TypeError: ifd.getElementsByTagName("textarea")[0] is undefined

My function that is used to action the post of the form is :

function uploadnewlogo(){

var logoDiv = dojo.byId('userlogo');
var logoMsg = dojo.byId('uploadmesg');

//prep the io frame to send logo data.
dojo.io.iframe.send({
    url: "/users/profile/changelogo/",
    method: "post",
    handleAs: "text",
    form: dojo.byId('logoUploadFrm'),
    handle: function(data,ioArgs){

        var response = dojo.fromJson(data);


        if(response.status == 'success'){

            //first clear the image
            //dojo.style(logoDiv, "display", "none");
            logoDiv.innerHTML = "";

            //then we update the image
            logoDiv.innerHTML = response.image;

        }else if(response.status == 'error'){

            logoMsg.innerHTML = data.mesg;

        }else{              

            logoMsg.innerHTML = '<div class="error">Whoops! We can not process your image.</div>';
        }

    },
    error: function(data, ioArgs){

        logoMsg.innerHTML = '<div class="error">' + data + '</div>';

    }
});

}

The form is very basic with just a File input component and a simple button that calls this bit of javascript and dojo.

I've got very similar code in my application that uploads word/pdf documents and that doesn't error, but for some reason this does.

Any ideas or pointers on what I should try to get this to work without errors?

Oh I'm using php and Zend framework for the backend if that has anything to do with it, but I doubt it as it's not even hitting the server before it fails.

Many thanks,

Grant

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about dojo