WeChat public account API multimedia Upload

Source: Internet
Author: User
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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.