脚本宝典收集整理的这篇文章主要介绍了php – 如何在上传之前和之后预览图像?,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
<form action="" method="post" enctyPE="multipart/form-data" name="personal_image" id="newHotnessForm"> <p><label for="image">Upload Image:</label> <input type="file" id="imageUpload"/></p> <p><button type="submIT" class="button">Save</button></p> <div id="preview"> <img width="160px" height="120px" src="PRofile pic.jpg" id="thumb" /> </div> </form>
并在下面合并了JS代码/脚本:
<script type="text/jaavascript"> $(document).ready(function(){ VAR thumb=$('#thumb'); new AjaxUpload('imageUpload',{ action:$('newHotnessForm').attr('action'),name:'image',onSubmit:function(file,extension){ $('#preview').addClass('loading'); },oncomplete:function(file,response){ thumb.load(function(){ $('#preview').removeClass('loading'); thumb.unbind(); }); thumb.attr('src',response); } }); });
我的表格上有两个主要问题:
1.为什么图像或图片的预览不起作用?
2.如何在单击保存按钮时粘贴表单中的照片,它将链接到我创建的另一个PHP或PHP页面?
<script type="text/javascript"> function readURL(input) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function (e) { $('#blah').attr('src',e.target.result); } reader.readAsDataURL(input.files[0]); } } </script> <body> <form id="form1" runat="server"> <input type='file' onchange="readURL(this);" /> <img id="blah" src="#" alt="your image" /> </form> </body>
工作演示here>
以上是脚本宝典为你收集整理的php – 如何在上传之前和之后预览图像?全部内容,希望文章能够帮你解决php – 如何在上传之前和之后预览图像?所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。