java - Problem uploading a file with ajax in appengine -
i need send content of file spring webservice ajax in google appengine application. i've used jquery ajaxfileupload plugin.
<form id="load_form" action="" enctype="multipart/form-data"> <input name="file" type="file" id="upload_files" value="browse"/> <input type="button"" id="upload_file" value="load file"/> </form>
the javascript looks this:
$("#upload_file").click(function(){ $.ajaxfileupload ( { url: '/myproject/uploadfile.json', secureuri: false, fileelementid: 'upload_files', datatype: 'json', success: function (data, status) { alert("ok"); }, error: function (data, status, e) { alert("error"); } } ); return false; });
and in controller:
@requestmapping(value="/uploadfile.json", method=requestmethod.post) public map<string, object> readfile( @requestparam(value = "file", required=false) multipartfile file, model model) throws exception{ ... }
the problem i'm having i'm not receiving in file parameter file content (it's null) , firebug can see i'm sending content of file in parameter called "file". i'm not receiving them though method invoked (i have breakpoint in , stops in it). if remove required=false file param 400 error given, looks cannot find file param.
i'm using spring 3.0.4.
any idea of may happening?
thanks.
if result oriented in case, can use custom servlet.
Comments
Post a Comment