layui文件上传 接口怎么写

layui文件上传 接口怎么写,第1张

<!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>

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 )


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/12140989.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-21
下一篇 2023-05-21

发表评论

登录后才能评论

评论列表(0条)

保存