Sometimes we need to post form data or upload file to a different domain it may be using PHP or ajax or jquery. But it is possible directly due to Same Origin Policy. So to achieve this task you need to enable certain configuration on your linux/ubuntu server. These are very simple and easy. Just follow the steps:

I) Check if your mod_headers module installed.

II) GoTO /etc/apache2/apache2.conf file, add following line of code under section:

Header set Access-Control-Allow-Origin “*”

if you want to post from any site, but it is not recommended as a security risk. Rather, you can mention a specific domain from which the request should be accepted just like:

Header set Access-Control-Allow-Origin “http://yourdomaintwo.com”

this will allow request from that specific domain only.

–allow cross domain file upload–