直接上代码
<!--支持快捷ajax传递数据--> <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <form action="./update.php" method="post" class="form-horizontal" role="form" enctype="multipart/form-data" id="uploadForm" name="uploadForm"> <a href="javascript:update()" id="update"> <span class="glyphicon glyphicon-upload"> <input type="file" name="file" id="file" accept="image/*" style="display:none;" onchange="upload(this)" /> </span> 上传 </a> </form> <script> function update() { $('#file').click(); } function upload(fileObj) { if (fileObj.value != '') { document.uploadForm.action = 'update.php'; document.uploadForm.submit(); } return false; } </script>
发表评论: