Get the App
SLTechnology News&Howtos  ›  Development  › 

An example of pseudo-ajax image upload code implementation

Shulou Source: shulou.com Published: 2022-06-03 14:10:35 11月14日 Update

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.

Tags: Code pictures examples more knowledge articles utility functions functions background objects that is work meetings ideas articles see knowledge points industry details information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Linux Docker MySQL Shulou Tech Info