How to use php+js+iframe to realize upload avatar interface without jump
This article will explain in detail how to use php+js+iframe to achieve no jump in the interface for uploading avatars. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
There are many ways to upload avatars with no jump in the interface. I use the one that adds an iframe. Let's go straight to the code.
Html:
The copy code is as follows:
/ / route is the backend interface
/ / upload/avatar is the saved address of the uploaded avatar
/ / imgurl=/upload/avatar/ the last one here is for the real-time display of the latest changed avatar with js, refer to the code in the js section below
/ / the saved name of the avatar is uid.type, such as 1.jpgPower2.png, etc.
/ / $user ['avatar'] if a user has uploaded an avatar, the avatar field in the user database will be time stamped, otherwise it will be empty