简单的无刷新上传

 upload.php

<?php
echo time();
?>
<br>
<form id="myform" target="mywin" action="file.php" method="post" enctype="multipart/form-data">
<input type=file name="img" onchange="document.getElementById('myform').submit();">
</form>
<img id=img1 src="">
<iframe name=mywin frameborder=0 width=0 height=0></iframe>
<br>
test
 

file.php

<?php

$tmp=$_FILES;
//print_r($tmp);
$tmp=$tmp["img"]["tmp_name"];
$time=time();
move_uploaded_file($tmp,"upload/".$time.".jpg");
$file=$time.".jpg";
//echo $file;
echo "<script>top.document.getElementById('img1').src='upload/".$file."';</script>";
?>

    A+
发布日期:2015年04月21日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: