Get the App
SLTechnology News&Howtos  ›  Database  › 

How to use PHP+Ajax to realize the preview function of uploading profile picture without refresh

Shulou Source: shulou.com Published: 2022-05-31 18:03:46 11月14日 Update

This article mainly explains the "how to use PHP+Ajax to achieve no refresh upload profile picture preview function", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use PHP+Ajax to achieve non-refresh upload profile picture preview function" it!

Upload avatar area

充值

Introduce jQuery library and plupload upload component plupload single picture upload configuration var uploader_avatar = new plupload.Uploader ({/ / Construction method of instance creation runtimes: 'gears,html5,html4,silverlight,flash', / / priority order of which way to initialize the upload plug-in browse_button: [' avatar_uplpad_btn'], / / upload button url: "ajax.php" / / remote upload address flash_swf_url: 'js/plugins/plupload/Moxie.swf', / / flash file address silverlight_xap_url:' js/plugins/plupload/Moxie.xap', / / silverlight file address filters: {max_file_size: '10mbupload, / / maximum upload file size (format 100b, 10kb, 10mb) 1gb) mime_types: [/ / allow file upload types {title: "files", extensions: "jpg,png,gif,jpeg"}]}, multi_selection: false, / / true:ctrl multiple file upload, false single file upload init: {FilesAdded: function (up, files) {/ / uploader_avatar.start before file upload () }, UploadProgress: function (up, file) {/ / upload, showing the progress bar var percent = file.percent; $("#" + file.id) .find ('.bar'). Css ({"width": percent + "%"}); $("#" + file.id) .find (".blank") .text (percent + "%") }, FileUploaded: function (up, file, info) {/ / trigger var data = eval ("(" + info.response + ")") when the file is uploaded successfully; / / parse the returned json data $("# avatar_pic") .html ("

")}, Error: function (up, err) {/ / trigger alert (err.message) when an upload error occurs;}); uploader_avatar.init () Thank you for your reading, the above is "how to use PHP+Ajax to achieve no refresh upload profile picture preview function" of the content, after the study of this article, I believe you on how to use PHP+Ajax to achieve no refresh upload profile picture preview function of this problem has a deeper understanding, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Files pictures avatars functions address learning content time maximum success priority area size instance that is ideas situations buttons plug-ins data Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Technology Redmi Apple Xiaomi