<!doctype html> <html> <head> <meta charset="utf-8"> <meta content="width=device-width, initial-scale=1.0" /> <link href="https://www.jb51.net/public/stylesheets/bootstrap.min.css" /> <link href="https://www.jb51.net/public/stylesheets/bootstrap-responsive.min.css" /> <link href="https://www.jb51.net/public/stylesheets/matrix-style.css" /> <link href="https://www.jb51.net/public/stylesheets/matrix-media.css" /> <script type="text/javascript" src="https://www.jb51.net/public/javascripts/jquery.min.js"></script> <script type="text/javascript" src="https://www.jb51.net/public/javascripts/jquery.form.js"></script> <script type="text/javascript" src="https://www.jb51.net/public/javascripts/jquery.validate.js"></script> <style type="text/css"> body{background:#eeeeee; margin:0px;} </style> </head> <body> <div> <label> 分享logo: </label> <div> <input type="file"/> <input type="hidden" value=""/>(<sapn>最佳大小为 80 X 80 像素</sapn>) <p><img src="https://www.jb51.net/public/img/default.png" alt=""></p> </div> </div> <script type="text/javascript"> $(function () { /*****************图片上传部分开始 *******************/ var act = "<form action='"+"<?php echo site_url('mytest/uploadfile');?>"+"' method='post' enctype='multipart/form-data'></form>"; $("#sharepic").change(function(){ $(this).wrap(act); $(this).parent(".myupload").ajaxSubmit({ dataType: 'json', success: function(data) { var src = data.pic; //更改预览图像地址 $('#sharepic_img').attr("src",src); $('#act_sharepic').val(data.name); $('#sharepic').unwrap(); }, error:function(xhr){ alert(JSON.parse(xhr)); } }); }); }) </script> </body> </html>
更多关于CodeIgniter相关内容感兴趣的读者可查看本站专题:《codeigniter入门教程》、《CI(CodeIgniter)框架进阶教程》、《php优秀开发框架总结》、《ThinkPHP入门教程》、《ThinkPHP常用方法总结》、《Zend FrameWork框架入门教程》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》