Home > Article > Backend Development > The image uploaded in WeChat obtains wxlocalresource://498448450243964 and is stored in the database but cannot be displayed on the front end.
Upload the image in WeChat and get wxlocalresource://498448450243964. The image is stored in the database and cannot be displayed on the front end. How to solve it
Upload the image in WeChat and get wxlocalresource://498448450243964. The image is stored in the database and cannot be displayed on the front end. How to solve it
This is a temporary local address. You need to obtain the file content after pulling the material on the server side and return the http address to the front end.
You should be using the picture interface of WeChat JSSDK
wxlocalresource://498448450243964 This is a photo local ID list that can only be used in the client’s own WeChat browser
You also need to use the image upload interface to upload images to the WeChat server:
<code>wx.uploadImage({ localId: 'wxlocalresource://498448450243964', // 需要上传的图片的本地ID,由chooseImage接口获得 isShowProgressTips: 1, // 默认为1,显示进度提示 success: function (res) { var serverId = res.serverId; // 返回图片的服务器端ID } });</code>
After uploading, this picture can only be saved on the WeChat server for 3 days, so you need to use the get material interface on the backend to save the picture to your own server
http request method: GET, https call
https://api.weixin.qq.com/cgi...
Request example (the example is to obtain multimedia files through the curl command)
curl -I -G "https:/ /api.weixin.qq.com/cgi-bin/media/get?>access_token=ACCESS_TOKEN&media_id=MEDIA_ID"