Submit form with file upload + cross domain

I am trying to submit a form in rails 4 with File upload(using
to an another domain using Ajax with dataType ‘jsonp’ ( I tried both
and ajaxForm ).

// .js
type: $(".form").attr(“method”),
dataType: “jsonp”,
url: $(".form").attr(“action”),
data: $(".form").serialize(),
success: function(data) {

I am getting the following error message.

Can’t verify CSRF token authenticity
Completed 422 Unprocessable Entity in 26ms


I can save data when i am not attach any file.

I got one solution,

skip_before_filter :verify_authenticity_token

I can save data by skipping verify authentication token. But I think
is not a secure way.

Can any one know a secure way? any suggestion please!

Note: I am getting all the params values in the destination domain.

File upload + Cross domain + Response

Is there anyway to upload file from one domain to another domain.

i used ajax post method to submit the form but i am not getting response

please suggest someway to solve this problem.

Thanks in advance!

On Fri, Jan 3, 2014 at 12:46 PM, saravanan p

Now you can “fake” an Ajax file upload with a hidden iframe, that’s been
popular since forever. It is a pain in the ass to get the response from
the server to refresh the actual page, though.


Only if you configure CORS, which usually means you have control over
both servers. Do you?