I have an html5 uploader thanks to the following tutorial: http://www.profilepicture.co.uk/ajax-file-upload-xmlhttprequest-level-2/ works great.. however I would like to upload the files to a different domain... I thought this would be possible as long as the domain, or more specifically the file on the domain I was uploading too had the follwong header:
由于以下教程,我有一个html5上传器:http://www.profilepicture.co.uk/ajax-file-upload-xmlhttprequest-level-2/工作得很好..但我想将文件上传到不同的域...我认为这是可能的,只要域名,或者更具体地说我上传的域名上的文件也有以下标题:
header("Access-Control-Allow-Origin: *")
Therefore allowing cross domain sharing... However the upload is not working, is there anything else I am missing, or is it a case that you can communicate across domains but you can't upload files? Kind regards to any responders...
因此允许跨域共享......但是上传不起作用,还有其他我缺少的东西,或者是否可以跨域通信,但无法上传文件?对任何响应者的亲切问候......
J
2 个解决方案
#1
0
I believe the best option for cross domain upload is to use ftp upload (of course you need to know ftp access credential such as ftp host, username and password.
我认为跨域上传的最佳选择是使用ftp上传(当然你需要知道ftp访问凭证,如ftp主机,用户名和密码。
If your using php as server side language you can try this little piece of code.
如果你使用php作为服务器端语言,你可以试试这段小代码。
I use this on multiple domains within the same web server.
我在同一个Web服务器中的多个域上使用它。
$conn_id = ftp_connect($server) or die("<span style='color:#FF0000'>Can't connect to ".$server."</span>");
$login_result = ftp_login($conn_id, $username, $password) or die();
$upload = ftp_put($conn_id, $server_path, $file, FTP_BINARY);
if (!$upload) {
echo "Error sending image to ".$server;
}
Hope this can help you.
希望这可以帮到你。
#2
0
You can use SlashUploader plugin, a JS plugin that allows cross-domain upload (and many other features as well)
您可以使用SlashUploader插件,一个允许跨域上传的JS插件(以及许多其他功能)
#1
0
I believe the best option for cross domain upload is to use ftp upload (of course you need to know ftp access credential such as ftp host, username and password.
我认为跨域上传的最佳选择是使用ftp上传(当然你需要知道ftp访问凭证,如ftp主机,用户名和密码。
If your using php as server side language you can try this little piece of code.
如果你使用php作为服务器端语言,你可以试试这段小代码。
I use this on multiple domains within the same web server.
我在同一个Web服务器中的多个域上使用它。
$conn_id = ftp_connect($server) or die("<span style='color:#FF0000'>Can't connect to ".$server."</span>");
$login_result = ftp_login($conn_id, $username, $password) or die();
$upload = ftp_put($conn_id, $server_path, $file, FTP_BINARY);
if (!$upload) {
echo "Error sending image to ".$server;
}
Hope this can help you.
希望这可以帮到你。
#2
0
You can use SlashUploader plugin, a JS plugin that allows cross-domain upload (and many other features as well)
您可以使用SlashUploader插件,一个允许跨域上传的JS插件(以及许多其他功能)