Copy Code code as follows:
<?php
if ($_files) {
?>
<script>
Window.parent.ajaxUploadPicture.uploadCallback (' yun_qi_img/5099213b07eca8065380ce7f75e95dda144ad348269.jpg ');
</script>
<?php
Die
}
?>
<! DOCTYPE html>
<script>
Ajaxuploadpicture = {$o 1: '};
Ajaxuploadpicture.ajaxuploadfile = function ($o) {
this. $o 1 = $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. $o 1.parentnode.insertbefore ($div, this. $o 1.nextSibling);
}else{
$div = document.getElementById (' picshow ');
}
$div. InnerHTML = ';
$div. appendchild ($pic);
};
</script>
<body>
<input type= "File" name= "file" onchange = "ajaxuploadpicture.ajaxuploadfile (this);" >
</body>
Object oriented thinking, form submits to a hidden IFrame, executes the callback JS function. Implement a picture echo. The function of the backstage PHP is not perfect.