<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <script type="text/javascript" src="jquery-2.1.4.min.js"></script> <script type="text/javascript"> $(function(){ var fil=$("#fil"); $("<img>").insertAfter("input"); fil.bind('change',function(){ var fordate=new FormData(); var fils=$("#fil").get(0).files[0]; fordate.append('pic',fils); var srcc=window.URL.createObjectURL(fils); console.log(srcc); $("img").attr({'src':srcc,'width':500+'px','heigth':500+'px'}); $.ajax({ url: "index4.php", type: "post", data: fordate, processData : false, contentType : false, success: function(html){ console.log(html); } }); }); }); </script> </head> <body> <input type="file" id="fil"> </body>
时间: 2024-11-09 00:05:46