The Great Gods, PHP service number development, there is no good picture upload plugin recommended. I find a picture upload plugin, the end is not very branch.
Reply content:
The Great Gods, PHP service number development, there is no good picture upload plugin recommended. I find a picture upload plugin, the end is not very branch.
This is usually the use of their own js-sdk
plug-in, the strategy is:
配置`js-sdk`,成功后调用接口比如:拍照、图片选择、图片上传,当然图片是上传到服务器的,然后你需要做的是在程序后端利用上传返回的`meidia_id`来下载上传的图片,这样就不需要自己找插件了,而且你自己找的插件上也不会支持的;
Wx.config ({debug:false,///Open debug mode, the return value of all API calls will come out at the client, to see the incoming parameters can be opened on the PC side, the parameter information will be typed through log, only on the PC side will be printed. AppId: ' {$appid} ',//required, the unique identifier of the public number timestamp: ' {$timestamp} ',//required, time stamp to generate the signature noncestr: ' {$noncestr} ',//required, RAW Signed random string signature: ' {$signature} ',//required, signed, see Appendix 1 jsapilist: [' chooseimage ', ' previewimage ', ' uploadimage ']//must The list of JS interfaces to be used, all JS interface lists are listed in Appendix 2}); $ (". Box-fill"). each (function () {var ele = $ (this); $ (this). Click (function () {wx.chooseimage ({count:1),//Default 9 SizeType: [' original ' , ' compressed '],//Can be specified as original or compressed, the default is SourceType: [' album ', ' Camera '],//You can specify whether the source is a photo album or a camera, the default is both Success:function (res) {var localids = Res.localids;//Returns a list of local IDs for the selected photo, Localid can be displayed as the SRC attribute of the IMG tag var $imgStr = ""; Ele.html ($IMGSTR); Wx.uploadimage ({localId:localIds.toString (),//RequiredThe local ID of the image to be uploaded, obtained isshowprogresstips:1 by the Chooseimage interface,//default is 1, Show progress prompt success: Function (res) {var serverid = Res.serverid;//Returns the server-side ID of the picture uploads Erverid (ServerID, Ele.data (' type ')); } }); } }); })})/** * Upload the service ID, which is the media_id * @param serverid * * * @param type of image uploaded by the server * * Function Uplo Adserverid (ServerID, type) {$.post ("{: U (' Uploadserverid ')}", {openId: "{$openid}", Serverid:serverid, Type:type}, function (ret) {if (Ret.status = =-1) {alert (ret.msg); }else if (ret.status = = 1) {if (ret.finish) {$ (". Filters"). Hide (); }}else{alert (' Please close the page and re-login to upload! '); } }) }
In addition, it is recommended that you go to the public platform to see the JS-SDK development documentation, as this involves something on the backend that requires some information to be done on the server, rather than on the front