Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use php+js+iframe to realize upload avatar interface without jump

Shulou Source: shulou.com Published: 2022-06-03 08:49:30 10月14日 Update

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

Tags: File picture avatar code extension content original image user path interface article storage function area name coordinates width data more standard Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Microsoft Apple MariaDB OPPO Reno