php7 uses curl to upload files and returns error code 26; the code is as follows:
<code> $size = filesize($path);//文件大小 $ch = curl_init($url); $cfile = curl_file_create($path); if (is_null($post_data)) { $data = array('media' => $cfile); }else{ $data = array('media' => $cfile,'description'=>$post_data); } curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_INFILESIZE,$size); curl_setopt($ch, CURLOPT_HEADER, 0); // 显示返回的Header区域内容 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回 $info = curl_exec($ch); if (curl_errno($ch)) { var_dump(curl_errno($ch)); return FALSE; } curl_close($ch); // 关闭CURL会话 return $info; // 返回数据</code>
I used the CURLFile function after checking the manual, but the error returned was still error code 26, or there was a lack of multimedia problems, etc.
<code> $cfile = new \CURLFile($path,$upload_type,$upload_name); </code>