There is such a requirement that users can change the displayed avatar. My idea is this: the user first uploads the avatar image, replaces the avatar image on the server, and then refreshes to display the updated image.
The question is, how can JS upload images to the server, combined with php or Nodejs
Just write a form to upload files
Write another php for file processing
http://www.jq22.com/jquery-in... Refer to the plug-in
Convert to base64 encoding, and ajax the encoding string to the backend to save it locally. It is best to compress the file in equal proportions before uploading.
The difficulty should be beautifying the upload button <input type="file" name="file" id="file" />.
ajaxupload
Take a look at this plug-in
The backend will process it normally. After the image is successfully saved, return the image address and then replace the image address on the page
Changed the code in the link