PHP7中文手册2018 带注释 最新chm版
- <?php
- /*
- 获取接口的方法
- 发送邮箱到 service@kuitao8.com
- 内容如下 域名:www.kuitao8.com(例子);
- 我们会将免费token发送到您的邮箱
- */
- $url = 'http://www.kuitao8.com/qrs/upload';
- $fname = realpath('21.png');
- $token = 'xxx';
- if (!class_exists('CURLFile')) {
- $post = array('file' => '@' . $fname,'token'=>$token);
- }
- else {
- $cfile = new CURLFile($fname);
- $post = array(
- 'file' => $cfile,
- 'token'=>$token
- );
- }
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
- curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type: multipart/form-data'));
- curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
- curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
- curl_setopt($ch, CURLOPT_TIMEOUT, 100);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
- if (class_exists('CURLFile')) {
- curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
- }
- $result = curl_exec ($ch);
- if ($result === FALSE) {
- echo "Error sending" . $fname . " " . curl_error($ch);
- curl_close ($ch);
- }else{
- curl_close ($ch);
- echo $result;
- }
- ?>
转载请注明:谷谷点程序 » php上传图片读取二维码的方法