Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

An example of pseudo-ajax image upload code implementation

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is to share with you about a pseudo-ajax picture upload code implementation example, the editor thinks it is very practical, so share it with you to learn, I hope you can get something after reading this article, say no more, follow the editor to have a look.

The code is as follows:

Window.parent.ajaxUploadPicture.uploadCallback ('https://cache.yisu.com/upload/information/20210311/307/14619.jpg'); ajaxUploadPicture = {$o1ajaxUploadPicture.ajaxUploadFile); ajaxUploadPicture.ajaxUploadFile = function ($o) {this.$o1 = $o; var $iframe = document.createElement (' iframe'); $iframe.style.display = 'none'; $iframe.name =' iframe'; $iframe.id = 'iframe'; document.body.appendChild ($iframe); var $form = document.createElement ("form"); $form.method = "post" $form.enctype = "multipart/form-data"; $form.action = ""; $form.target = 'iframe'; $newO = $o.cloneNode (); $form.appendChild ($newO); $form.submit ();} ajaxUploadPicture.uploadCallback = function ($url) {$pic = document.createElement (' img'); $pic.width = "200"; $pic.height =" 150"; $pic.src = $url; if (document.getElementById ('picshow') = null) {$div = document.createElement ("div"); $div.id =' picshow' This.$ o1 [XSS _ clean] .insertBefore ($div,this.$o1.nextSibling);} else {$div = document.getElementById ('picshow');} $div [XSS _ clean] ='; $div.appendChild ($pic);}

With object-oriented thinking, form submits to a hidden iframe and executes the callback js function. Achieve picture echo. The function of background php is not perfect.

The above is an example of pseudo-ajax image upload code implementation. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report