How to upload material php code in Wechat
How to upload material php code in Wechat, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
Url: Wechat's api interface for uploading media materials.
$path_img: the absolute path to the server file
The absolute path here is not a temporary path in $_ FILES, otherwise an exception of the wrong file type will be reported.
Private function HttpsUpdateFileServerRequest ($url,$path_img) {$curl = curl_init (); if (class_exists ('\ CURLFile')) {/ / php > = version 5.6$ filedata=array ('media' = > new\ CURLFile (realpath ($path_img)); curl_setopt ($curl, CURLOPT_SAFE_UPLOAD, true);} else {/ / php < version 5.6$ filedata=array (' media' = >'@'. $path_img) If (defined ('CURLOPT_SAFE_UPLOAD')) {curl_setopt ($curl, CURLOPT_SAFE_UPLOAD, false);}} curl_setopt ($curl, CURLOPT_URL, $url); curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, FALSE); if (! Empty ($filedata) {curl_setopt ($curl, CURLOPT_POST, 1); curl_setopt ($curl, CURLOPT_POSTFIELDS, $filedata);} curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec ($curl); curl_close ($curl); return $output;} after reading the above, have you mastered how to upload the php code of the material on Wechat? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!