About Public Account API multimedia Upload about public account API multimedia upload,
API documentation:
You can call this interface to upload images, audios, videos, and other files to the server. after the files are uploaded, the server returns the corresponding media_id. the public account can then be used to obtain multimedia files based on the media_id. Please note that media_id is reusable and the http protocol is required to call this interface.
API call request description
Http request method: POST/FORM
Http://file.api.weixin.qq.com/cgi-bin/media/upload? Access_token = ACCESS_TOKEN & type = TYPE
Call example (use the curl Command to upload a multimedia file using FORM ):
Curl-F media@@test.jpg "http://file.api.weixin.qq.com/cgi-bin/media/upload? Access_token = ACCESS_TOKEN & type = TYPE"
I wrote a php code, and the returned prompt is always: {"errcode": 41005, "errmsg": "media data missing "}
This is not the reason for a long test. please give me some advice and score 100 points.
Reply to discussion (solution)
My php code:
Function get_pic_mediaid ($ picname = ''){
$ Type = "image ";
$ Url = "http://file.api.weixin.qq.com/cgi-bin/media/upload? Access_token = % s & type = % s ";
$ Access_token = get_current_access_token ();
$ Url = sprintf ($ url, $ access_token, $ type );
$ Filepath = dirname (_ FILE _). '/resource/attachment/'. $ picname;
$ Filedata = array ("media" => '@'. $ filepath );
$ Resp = ihttp_post ($ url, $ filedata );
Var_dump ($ resp); exit;
}
Note: $ picname isName of the uploaded file. The image is successfully uploaded and can be found in the $ filepath path.
$ Resp = ihttp_post ($ url, $ filedata );
Var_dump ($ resp); exit;
What are the prompts?
{& Quot; errcode & quot;: 41005, & quot; errmsg & quot;: & quot; media data missing & quot "}
Hi, have you found a solution ?? I also encountered this problem. can you share it? Qq0000476065
I tested it locally and put the code on the server for 41005. do you have this problem?
The problem has not been solved for 14 years... Is it solved now?
16 years ago. The problem has not been solved yet... Is it solved now?