TP5基于Bootstrap3可预览的HTML5⽂件上传插件(单⽂件测
试成功)
view上传页⾯
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
asp源码论文<title>头部-有点</title>
<link href="www.jq22/jquery/bootstrap-3.3.4.css" rel="stylesheet">
<link href="/css/admin/fileinput.css" media="all" rel="stylesheet" type="text/css" />
<script src="www.jq22/jquery/1.11.1/jquery.min.js"></script>
<script src="/js/admin/fileinput.js" type="text/javascript"></script>
<script src="/js/admin/fileinput/locales/zh.js" type="text/javascript"></script>
<script src="www.jq22/jquery/bootstrap-3.3.4.js" type="text/javascript"></script>
</head>
<body>
<form action="{:url('Coupon/coupon_add')}" method="post" enctype="multipart/form-data">
<input name="coupon_imageurl" id="img" type="hidden" value=""><!-⽤于把上传的图⽚地址放到隐藏框提交更新到数据库-!>
<div class="bbD" >
<div class="form-group">
图⽚:<input id="file-1" type="file" multiple class="file" data-overwrite-initial="false" name="file">
</div>
</div>
<div class="bbD">
<p class="bbDP">
<button class="btn_ok btn_yes" href="#" type="submit">提交</button>
<a class="btn_ok btn_no" href="#">取消</a>
</p>
</div>
</form>
<!-- 上传⼴告页⾯样式end -->
<script>
$("#file-1").fileinput({
language: 'zh', //设置语⾔中⽂
uploadUrl: "{:url('coupon/upload_images')}", // 必须设置个路径进⼊php代码部分
uploadAsync:true,//⽤异步上传
allowedFileExtensions : ['jpg', 'png','gif','txt','zip','ico','jpeg','js','css','java','mp3','mp4','doc','docx'],//允许的⽂件类型
overwriteInitial: false,
maxFileSize: 1500,//⽂件的最⼤⼤⼩单位是k
maxFileCount:1, //最多⽂件数量
// allowedFileTypes: ['image', 'video', 'flash'],
}).on("fileuploaded", function (event,data) {
sponse)
{
}
//$("#img").val(event.image_url);
});
</script>
</body>
</html>
后台控制器⾥写的⽅法
/**
* 优惠券添加
*
*/
jquery下载文件插件public function coupon_add()
{sql2000安装教程64位
$request = Request::instance();
if($request->isPost())
{
dump($request->post('coupon_imageurl'));
}
return $this->fetch();
}
/**strcpy strncpy
*
* ⽂件上传
*/
public function upload_images()
{
$request = Request::instance();
if($request->isPost()) {
$file = $request->file('file');
$info = $file->move(ROOT_PATH . 'public' . DS . 'uploads');
//上传成功
if ($info) {
$data['image_url'] = str_replace("\\", "/", "" . $_SERVER['SERVER_NAME'] . "/uploads/" . $info->getSaveName()); echo json_encode($data);
css同时选择两个class} else {
//上传失败获取错误信息
die('{"flag" : "0"}');
electric是什么牌子}
}
}
html⾥要引⼊的⽂件资源地址
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论