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