我从我的
PHP服务器复制了一个工作脚本,但出于开发目的,我希望它可以在我的本地XAMPP服务器上运行.
cURL:
$realpath_curl_file = realpath($curl_file); $post = array( 'recipient_number' => $recipient_number,'user_id' => $user_id,'up_file'=> "@$realpath_curl_file" ); //prepare data for cUrl $target_url = "http://api.blankthis.com/curl/outgoing"; $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$target_url); curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch,CURLOPT_POSTFIELDS,$post); curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE); $result = curl_exec ( $ch ); $err = curl_errno ( $ch ); $errmsg = curl_error ( $ch ); $header = curl_getinfo ( $ch ); $httpCode = curl_getinfo ( $ch,CURLINFO_HTTP_CODE ); print_r($result); echo '------------------------'; print_r($ch); print_r($err); print_r($errmsg); print_r($header); print_r($httpCode);
当我执行print_r($_ POST)和print_r($_ FILES)时,没有文件被传输.这是我的结果:
POST:Array ( [recipient_number] => 2394434455 [user_id] => 2 [up_file] => @C:\Users\Sharktek\AppData\Local\Temp\1422046077466.zip ) FILES:Array ( ) ------------------------ Resource id #570 Array ( [url] => http://api.redfax.com/curl/outgoing [content_type] => text/html; charset=UTF-8 [http_code] => 200 [header_size] => 202 [request_size] => 196 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.499 [namelookup_time] => 0.125 [connect_time] => 0.218 [pretransfer_time] => 0.218 [size_upload] => 409 [size_download] => 168 [speed_download] => 336 [speed_upload] => 819 [download_content_length] => 168 [upload_content_length] => 409 [starttransfer_time] => 0.359 [redirect_time] => 0 [redirect_url] => [primary_ip] => 107.191.119.155 [certinfo] => Array ( ) [primary_port] => 80 [local_ip] => 192.168.0.101 [
有谁知道为什么我的文件没有通过cURL上传?正如我所说,这可以很好地从我的服务器(非本地主机)
> XAMPP PHP安装已启用cURL
>我禁用了我的防火墙
检查你的PHP.ini,你的apache conf文件,重启,重复,重复并重复…
原文链接:/php/132650.html或者如果您遇到与我相同的问题,并且知道已加载curl,但只是没有执行外部请求,请尝试将此选项添加到您的卷曲中
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
This option determines whether curl verifies the authenticity of the
peer’s certificate
问题可能是由于拥有最新的证书.
特别是如果您在Windows上进行开发并使用XAMPP或某些类似服务,则默认情况下不会加载证书.在Linux上,这不太可能被要求.
对于生产用途,您应该修复根问题,而不是允许此漏洞影响您的服务器通信.