Usually a client-side script is not allowed accessing data that resides outside a domain where the script is hosted. It means that you usually cannot host HTML5 Uploader on one domain and upload files to another. However, you can manage this task by enabling Cross-Origin Resource Sharing (CORS).
To grant client scripts basic access to your resources simply add one HTTP Response Header:
Access-Control-Allow-Origin: *
The asterisk permits scripts hosted on any site to load your resources.
To permit scripts hosted on only a specific site to load your resources use an origin (protocol+domain+optional port):
Access-Control-Allow-Origin: http://example.com:8080
You can enable CORS by configuring server settings or by configuring HTTP response header from your script.
Apache can be configured to expose this header using mod_headers, this is enabled by default in Apache however you may want to ensure it is enabled by running the following command: a2enmod headers
To expose the header you simply add the following line inside <Directory>, <Location>, <Files> or <VirtualHost> sections, or within a .htaccess file:
Header set Access-Control-Allow-Origin *
"*" means that CORS will be enabled for any domain name. If you need to use an exact name please specify it instead of "*".
Perform the following steps:
"*" means that CORS will be enabled for any domain name. If you need to use an exact name please specify it instead of "*".
For Microsoft IIS7, merge this into the web.config file at the root of your application or site:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>"*" means that CORS will be enabled for any domain name. If you need to use an exact name please specify it instead of "*".
If you do not have access to configure your web server, you can still send the header from your script.
Add the following code to your PHP scripts:
<?php
header("Access-Control-Allow-Origin: *");
...
?>"*" means that CORS will be enabled for any domain name. If you need to use an exact name please specify it instead of "*".
Add the following line to your source code:
Response.AppendHeader("Access-Control-Allow-Origin", "*");"*" means that CORS will be enabled for any domain name. If you need to use an exact name please specify it instead of "*".