本文目录一览:
- [layui文件上传 接口怎么写](#layui文件上传 接口怎么写)
- layui文件上传接口怎么写
- 如何接收layui上传excel上传及php处理
- [如何接收layui上传的信息 php](#如何接收layui上传的信息 php)
- 使用layui前端框架,进行分页,php怎样传递数据
- layui分页怎么配合php使用
layui文件上传 接口怎么写
!DOCTYPE html
<html>
<head>
<meta charset="UTF-8">
<title>文件上传</title>
<link rel="stylesheet" href="layui/css/layui.css">
<link rel="stylesheet" href="css/global.css">
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
<legend>设定上传文件的格式</legend>
</fieldset>
<input type="file" name="file" class="layui-upload-file">
<input type="file" name="file1" lay-type="file" class="layui-upload-file">
<input type="file" name="file1" lay-type="audio" class="layui-upload-file">
<input type="file" name="file2" lay-type="video" class="layui-upload-file">
<blockquote class="layui-elem-quote" style="margin-top: 20px;">支持拖动文件上传</blockquote>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
<legend>演示上传</legend>
</fieldset>
<div class="site-demo-upload">
<img id="LAY_demo_upload" src="layui/images/tong.jpg">
<div class="site-demo-upbar">
<input type="file" name="file" class="layui-upload-file" id="test">
</div>
</div>
<p style="margin-top: 20px;">注:由于服务器资源有限,所以此处每次给你返回的是同一张图片</p>
<script src="layui/layui.js"></script>
<script>
layui.use('upload', function(){
layui.upload({
url: '' //上传接口
,success: function(res){ //上传成功后的回调
console.log(res)
}
});
layui.upload({
url: '/test/upload.json'
,elem: '#test' //指定原始元素,默认直接查找class="layui-upload-file"
,method: 'get' //上传接口的http类型
,success: function(res){
LAY_demo_upload.src = res.url;
}
});
});
</script>
</body>
</html>
layui文件上传接口怎么写
require_once "../common_mysql.php";
require_once MESSAGE_PATH . 'zh/zh_calendar_message.php';
require_once "function_common/user_function.php";
require_once "function_common/public_function.php";
global $DB;
$sql_time = microtime(true);
//$uid = $self_userid;
//保存图片
$json_result['status'] = 0;
$path = 'upfile';
$json_result['status'] = 0;
$json_result['successmsg'] = '传失败';
if (isset($_FILES['imageZip'])) {
$upfile = 'upfile/' . $_FILES['imageZip']['name'];
if (!@file_exists($path)) {
@mkdir($path);
}
$result = @move_uploaded_file($_FILES['imageZip']['tmp_name'], $upfile);
if (!$result) {
$json_result['status'] = 0;
$json_result['successmsg'] = '传失败';
$json_result['datas'] = array('savePath' => $upfile);
exit(json_encode($json_result));
}
}
$json_result['status'] = 1;
$json_result['datas'] = array('savePath' => $upfile);
如何接收layui上传excel上传及php处理
PHP 把数据导出到excel表格有多种方法,比如使用 phpExcel 等,以下代码是直接通过 header 生成 excel 文件的代码示例:
<?php
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=xls_region.xls");
$cfg_dbhost = 'localhost';
$cfg_dbname = 'testdb';
$cfg_dbuser = 'root';
$cfg_dbpwd = 'root';
$cfg_db_language = 'utf8';
// END 配置
//链接数据库
$link = mysql_connect($cfg_dbhost, $cfg_dbuser, $cfg_dbpwd);
mysql_select_db($cfg_dbname);
//选择编码
mysql_query("set names " . $cfg_db_language);
//users表
$sql = "desc users";
$res = mysql_query($sql);
echo "<table><tr>";
//导出表头(也就是表中拥有的字段)
while ($row = mysql_fetch_array($res)) {
$t_field[] = $row['Field']; //Field中的F要大写,否则没有结果
echo "<th>" . $row['Field'] . "</th>";
}
echo "</tr>";
//导出100条数据
$sql = "select * from users limit 100";
$res = mysql_query($sql);
while ($row = mysql_fetch_array($res)) {
echo "<tr>";
foreach ($t_field as $f_key) {
echo "<td>" . $row[$f_key] . "</td>";
}
echo "</tr>";
}
echo "</table>";
?>
等等 许多, 具体的在后盾网里面有详细的。
如何接收layui上传的信息 php
action
直接空,直接用 submit
按钮,点击不就提交到当前页面了额,<input id="submit1" name="submit1" type="button">
你这个地方干嘛用 button
,用 submit
按钮额。
我这样说或许你还不懂,就去找后盾人吧,我在后盾人学了很多。
使用layui前端框架,进行分页,php怎样传递数据
//以下将以jquery.ajax为例,演示一个异步分页
function demo(curr){
$.getJSON('test/demo1.json', {
page: curr || 1 //向服务端传的参数,此处只是演示
}, function(res){
//此处仅仅是为了演示变化的内容
var demoContent = (new Date().getTime()/Math.random()/1000)|0;
document.getElementById('view1').innerHTML = res.content + demoContent;
//显示分页
laypage({
cont: 'page1', //容器。值支持id名、原生dom对象,jquery对象。【如该容器为】:<div id="page1"></div>
pages: res.pages, //通过后台拿到的总页数
});
});
}
我还是比较推荐你去后盾人上面看看里面有很多这类php之类的教学讲解视频哦。
layui分页怎么配合php使用
0
代表开始的下标,比如一页显示 10
条的话,那么第一页就是 0,10
,第二页就是 (2-1)*10,10
,第三页就是 (3-1)*10,10
,所以你那个 0
就是写 limit ($page-1)*$pagenum,$pagenum
。