简体   繁体   English

将照片上传到远程服务器PHP

[英]Upload a photo to remote server PHP

I want to upload a file to a remote which can be downloaded from a url. 我想将文件上传到可以从网址下载的遥控器。 Below is the code that I used to do that, but the $response that I get says that file is not received in the server end. 下面是我过去常用的代码,但是我得到的$ response表示在服务器端没有收到该文件。

$path = "http://image-server/image.jpg";

$ch=curl_init();

curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);

curl_setopt($ch,CURLOPT_URL,"https://my-server/files/images");

curl_setopt($ch,CURLOPT_POST,true);

$post=array("content"=>$path);

curl_setopt($ch,CURLOPT_POSTFIELDS,$post);

$response=curl_exec($ch);

FYI : the file needs to be sent as the value for a parameter(content). 仅供参考:文件需要作为参数(内容)的值发送。

Thanks. 谢谢。

Please take a look at the servers access.log if the request arrives there and then check the error.log if an error occoured. 如果请求到达那里,请查看服务器access.log,如果发生错误,请检查error.log。

It might be the SSL Connection. 它可能是SSL连接。 Can you try the post without SSL? 你可以试试没有SSL的帖子吗?

Take a look at this for SSL and cURL: 看看这个SSL和cURL:

http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/ http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM