WeChat enterprise JS-SDK: upload pictures, js-sdk upload pictures

Source: Internet
Author: User

Enterprise ID JS-SDK: upload pictures, js-sdk upload pictures

The JS-SDK provides client-related functions, such as: photo, select the figure, voice, location and other mobile phone system capabilities, at the same time can be directly used to share, scan and other unique capabilities, provide users with a better Web experience. This explains how to upload an image from a cell phone camera or album by calling the JS-SDK interface.

Directory

1. Introduction

2. Sample Code

 

1. Introduction 1.1 process description

First, let's take a look at the entire Demo process:

① Client access page ② get related permissions in JS-SDK

API: Http://qydev.weixin.qq.com/wiki/index.php? Title = JS-SDK Interface

Description: Want to use specific operation before the operation to apply for related JS-SDK permissions, here will apply for image interface.

③ Select images on the client

API: JS-SDK image interface: Select image from mobile phone

Description: In this step, the client only selects images from the mobile phone and does not upload them to the server. Each selected image generates a localId.

④ Upload an image to the server to obtain the serverId

API: JS-SDK image interface: upload images to servers

Description: Upload the localId to the server. After successful upload, The serverId of each image is returned.

⑤ Store the serverId on the page and submit it to the Business Server

Description: Store the previous image serverId on the page and submit it to the Business Server.

⑥ The Business Server obtains the specified image from the server based on the serverId

API: Http://qydev.weixin.qq.com/wiki/index.php? Title = get a temporary clip file

Description: The Business Server requests the server to obtain the image and store it locally based on the obtained serverId (media_id.

 

1.2 Flowchart

 

2. code example 2.1 front-end HTML page

After the page is loaded, an image interface for obtaining the JS-SDK is requested:

Window. addEventListener ('load', function () {// reg wxconfig Ak. http. get ({url: '/WeChat/ImageTest/GetImageJsSdk', params: {url: location. href. split ('#') [0] // It must contain information such as code = XXXX & state}, isHideLoading: true, successCallback: function (res) {wx. config (res. data );}});});

  

2.2 runtime Diagram

 

2.3 download Demo

: Http://files.cnblogs.com/files/polk6/WeChat.QYH.zip

 

====================================== Series of articles ==============================================

This article: 1.4 enterprise JS-SDK: upload pictures

Development Article navigation

 

Related Article

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.