<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <script src="jq183.js"></script> <script> function ajaxup(){ var ifname = ‘up‘+Math.random(); $("<iframe name=‘"+ ifname +"‘></iframe>").appendTo($(‘body‘)); $(‘form:first‘).attr(‘target‘,ifname); return false; } </script> </head> <body> <form action="9.php" method="post" enctype="multipart/form-data" onsubmit="return ajaxup();"> <input type="file" name="pic"> <br> <br> <input type="submit" value="GO"> </form> </body> </html>
我们众所周知后端error如果等于 相当于上传成功,所以暂时用一个临时数据来模拟下意思
<?php if(empty($_FILES)){ exit(‘No file‘); } echo $_FILES[‘pic‘][‘error‘] == 0 ? ‘success‘:‘error‘;
时间: 2024-10-07 11:28:11