当前位置:网站首页>上传文件/文本/图片,盒子阴影
上传文件/文本/图片,盒子阴影
2022-06-26 02:49:00 【小菜鸟码住】
上传文件
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
div{
width: 200px;
height: 200px;
border: 1px solid black;
box-shadow: 3px 3px 3px 3px;
font-size: 30px;
margin: 0 auto;
}
</style>
</head>
<body>
<div>你好</div>
<input id="file" multiple type="file">
<button id="btn">上传文件</button>
<ul id="msg">
<li></li>
<li></li>
</ul>
</body>
<script>
// var file = document.querySelector('#file');
var file = document.getElementById('file');
var btn = document.getElementById('btn');
var msg = document.getElementById('msg');
btn.onclick = function(){
var reader = new FileReader();
reader.readAsText(file.files[0]);
// reader.readAsDataURL(file.files[0]);
reader.onload = function(){
console.log(this.result)
// msg.children[0].innerHTML = '<img src=''>'
}
// msg.children[0].innerHTML = file.files[0].name;
// console.log(file.files);
// for(var i=0;i<file.files.length;i++){
// if(!/image/.test(file.files[i].type)){
// if(file.files[i].type.indexOf('image')===-1){
// alert('文件格式不对');
// return;
// }
// }
// alert('上传成功');
}
//异步
//同步
console.log(1);
console.log(2);
alert(3);
setTimeout(function(){
console.log(4);
},3000)
console.log(5);
</script>
</html>

边栏推荐
- Interpreting Oracle
- Learn from Taiji makers - mqtt (V) publish, subscribe and unsubscribe
- Literature reading --- optimize RNA SEQ research to study herbicide resistance (review)
- 丝网印刷的种类及其应用方法
- Camtasia 2022 nouvelle vidéo d'ordinateur d'enregistrement ultra - clair
- [machinetranslation] - Calculation of Bleu value
- [flask introduction series] flask processing request and response
- 计组笔记——CPU的指令流水
- Analysis on the diversification of maker space mechanism construction
- Dreamcamera2 record key prompt sound into video during video recording
猜你喜欢

解析少儿编程的多元评价体系

计组笔记——CPU的指令流水

Good news | congratulations on the addition of 5 new committers in Apache linkage (incubating) community

【论文笔记】Supersizing Self-supervision: Learning to Grasp from 50K Tries and 700 Robot Hours

【哈希表】很简单的拉链法哈希结构,以至于效果太差,冲突太多,链表太长

Little p weekly Vol.10

学习太极创客 — MQTT(五)发布、订阅和取消订阅

Camtasia 2022 nouvelle vidéo d'ordinateur d'enregistrement ultra - clair

工作室第3次HarmonyOS培训笔记

工业机器人之“慧眼”——机器视觉
随机推荐
路由跳转之点击列表的操作按钮,跳转至另一个菜单页面并激活相应的菜单
Redis configuration and optimization of NoSQL
Create a nonlinear least squares test in R
Hardware creation principle of campus maker space
Cliquez sur le bouton action de la liste pour passer à une autre page de menu et activer le menu correspondant
Utonmos: digital collections help the inheritance of Chinese culture and the development of digital technology
Une citation classique de la nature humaine que vous ne pouvez pas ignorer
[machinetranslation] - Calculation of Bleu value
【哈希表】很简单的拉链法哈希结构,以至于效果太差,冲突太多,链表太长
丝网印刷的种类及其应用方法
Qt编译出错ERROR: Unknown module(s) in QT: script
Analysis of technological changes in social robots
如何筹备一场感人的婚礼
网络PXE启动WinPE,支持UEFI和LEGACY引导
Inkscape如何将png图片转换为svg图片并且不失真
小程序或者for循序要不要加key?
国信金太阳靠谱吗?开证券账户安全吗?
[flask introduction series] flask processing request and response
显卡、GPU、CPU、CUDA、显存、RTX/GTX及查看方式
学习太极创客 — MQTT(四)服务端连接操作