当前位置: 首页 > news >正文

网站开发所需的费用网站推广主要是做什么

网站开发所需的费用,网站推广主要是做什么,做网站济南,网页设计作品集图片随着Web应用的普及,文件上传功能成为许多网站和应用不可或缺的一部分。本文整理了个人学习过程中的笔记,为开发者提供全面的了解和实践经验。 单文件上传 在早期的html应用中,都是使用form标签中嵌套来实现文件上传的,具体代码如…

随着Web应用的普及,文件上传功能成为许多网站和应用不可或缺的一部分。本文整理了个人学习过程中的笔记,为开发者提供全面的了解和实践经验。

单文件上传

在早期的html应用中,都是使用form标签中嵌套来实现文件上传的,具体代码如下

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>单文件上传示例</title>
</head>
<body><form action="/upload" method="post" enctype="multipart/form-data"><label for="fileInput">选择文件:</label><input type="file" id="fileInput" name="fileInput"><button type="submit">上传文件</button></form>
</body>
</html>

上述实现方式是最原始也是最简单的代码实现,详细的元素说明如下

  • <form> 元素包含了文件上传的整个表单,action 属性指定了处理文件上传的服务器端脚本,method 属性指定了表单提交的HTTP方法为 postenctype 属性设置为 multipart/form-data 以支持文件上传。
  • <label> 元素用于显示文本标签,上述示例中label跟元素联动,提升用户体验。
  • <input type="file"> 是文件上传的核心元素,它创建了一个文件选择框。id 属性用于关联 <label> 元素,name 属性用于标识在提交表单时的字段名。
  • <button> 元素用于提交表单。

这只是一个基本的HTML结构,实际上,要使文件上传功能更加完善,还需要使用后端技术来处理文件的接收和存储。涉及后端的代码逻辑就不在这里陈述了。后续会专门编写后端接收文件上传的相关文章。

另外单文件上传还可以结合JavaScript语言来实现,以下是一个简单的例子,演示如何使用JavaScript结合HTML实现文件上传,并通过Ajax发送文件到服务器

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>JavaScript文件上传示例</title>
</head>
<body><input type="file" id="fileInput" /><button onclick="uploadFile()">上传文件</button><progress id="progressBar" value="0" max="100"></progress><div id="status"></div><script>function uploadFile() {var fileInput = document.getElementById('fileInput');var progressBar = document.getElementById('progressBar');var status = document.getElementById('status');var file = fileInput.files[0];if (!file) {status.innerHTML = '请选择文件';return;}var formData = new FormData();formData.append('file', file);var xhr = new XMLHttpRequest();xhr.open('POST', '/upload', true);xhr.upload.onprogress = function (e) {if (e.lengthComputable) {var percent = (e.loaded / e.total) * 100;progressBar.value = percent;status.innerHTML = percent.toFixed(2) + '% 上传中...';}};xhr.onreadystatechange = function () {if (xhr.readyState === 4 && xhr.status === 200) {status.innerHTML = '上传完成';} else if (xhr.readyState === 4 && xhr.status !== 200) {status.innerHTML = '上传失败';}};xhr.send(formData);}</script>
</body>
</html>

本人这里也提供一个基于Vue3的文件上传实现,代码如下

<template><el-dialogclass="upload-file-dialog"title="文件上传"width="600px"height="300px"><el-row class="file-info"><el-col :span="12" class="file-info-name"><span class="title">当前文件夹:</span><span class="content">{{folderObj.filename}}</span></el-col><el-col :span="12" class="file-info-update-time"><span class="title">最后更新时间:</span><span class="content">{{folderObj.updateTime}}</span></el-col></el-row><el-row><el-col><el-upload:auto-upload="false"class="upload-demo"dragaction="#"multiple:on-change="uploadContext.handleChange"v-model:file-list="formData.fileList"><el-icon class="el-icon--upload"><upload-filled /></el-icon><div class="el-upload__text">拖动文件到这里或者<em>点击上传</em></div><template #tip><div class="el-upload__tip">文件大小不超过10MB</div></template></el-upload></el-col></el-row><el-row class="btns"><el-col><el-button type="primary" @click="uploadContext.upload">开始上传</el-button></el-col></el-row></el-dialog>
</template><script setup>
import { onMounted, reactive, getCurrentInstance } from 'vue'
import axios from 'axios'
const props = defineProps(['folderObj'])
const that = getCurrentInstance()
const ctx = that.ctx    //当前实例的上下文
const formData = reactive({fileList: [],imgSrc: ''
})const uploadContext = {upload: ()=>{formData.fileList.forEach((item, index)=>{let formData = new FormData()formData.append('fileId', item.uid)formData.append('filename', item.name)formData.append('file', item.raw)formData.append('fileSize', item.size)formData.append('fileSizeDesc', item.size + '')formData.append('fileSuffix', item.name.substring(item.name.lastIndexOf(".")+1))formData.append('identifier', item.raw.type)axios.post('/pan/file/upload', formData).then(res=>{console.log(res)	//显示上传文件结果})})},/*** 文件上传控件变化处理,这里可以增加进度条的显示处理逻辑,本人这里就处理这块代码逻辑了*/handleChange: (uploadFile, uploadFileList)=>{console.log(formData.fileList)}
}</script><style lang="scss">
.upload-file-dialog {.el-dialog__body{padding: 10px 15px;}.file-info{padding: 0 0 5px 0;.file-info-update-time{text-align: right;}}.btns{.el-col{text-align: right;}}
}
</style>

文章转载自:
http://mylohyoid.jnpq.cn
http://knackered.jnpq.cn
http://discovrery.jnpq.cn
http://palfrey.jnpq.cn
http://rigidness.jnpq.cn
http://redrew.jnpq.cn
http://tadzhiki.jnpq.cn
http://maraschino.jnpq.cn
http://looney.jnpq.cn
http://prolapsus.jnpq.cn
http://tittup.jnpq.cn
http://nonexportation.jnpq.cn
http://methodology.jnpq.cn
http://kris.jnpq.cn
http://cotransduction.jnpq.cn
http://transplant.jnpq.cn
http://erythrocytosis.jnpq.cn
http://flinty.jnpq.cn
http://forswore.jnpq.cn
http://agony.jnpq.cn
http://federate.jnpq.cn
http://camphoric.jnpq.cn
http://preachify.jnpq.cn
http://halfvolley.jnpq.cn
http://unguled.jnpq.cn
http://dharna.jnpq.cn
http://rightfully.jnpq.cn
http://buckaroo.jnpq.cn
http://bunchy.jnpq.cn
http://snicket.jnpq.cn
http://exultingly.jnpq.cn
http://jagged.jnpq.cn
http://decistere.jnpq.cn
http://endodermis.jnpq.cn
http://unboastful.jnpq.cn
http://suva.jnpq.cn
http://galvanocautery.jnpq.cn
http://inexhaustibility.jnpq.cn
http://thiophenol.jnpq.cn
http://foraminifera.jnpq.cn
http://decide.jnpq.cn
http://gaskin.jnpq.cn
http://naught.jnpq.cn
http://diphosphate.jnpq.cn
http://tinware.jnpq.cn
http://calotte.jnpq.cn
http://flatten.jnpq.cn
http://horra.jnpq.cn
http://sneezy.jnpq.cn
http://trackless.jnpq.cn
http://thermomotor.jnpq.cn
http://refold.jnpq.cn
http://carsickness.jnpq.cn
http://preoccupant.jnpq.cn
http://lacquer.jnpq.cn
http://pks.jnpq.cn
http://bureaucratise.jnpq.cn
http://hopbine.jnpq.cn
http://wismar.jnpq.cn
http://formality.jnpq.cn
http://kinetic.jnpq.cn
http://videoland.jnpq.cn
http://climatize.jnpq.cn
http://anfractuous.jnpq.cn
http://microminiature.jnpq.cn
http://sectional.jnpq.cn
http://monosaccharose.jnpq.cn
http://kirsen.jnpq.cn
http://biannually.jnpq.cn
http://asteriated.jnpq.cn
http://classis.jnpq.cn
http://supranationalism.jnpq.cn
http://blackcock.jnpq.cn
http://ruddy.jnpq.cn
http://vodka.jnpq.cn
http://zanu.jnpq.cn
http://suilline.jnpq.cn
http://japanner.jnpq.cn
http://moneychanger.jnpq.cn
http://justiciable.jnpq.cn
http://spicous.jnpq.cn
http://delirium.jnpq.cn
http://racing.jnpq.cn
http://bacteriolysin.jnpq.cn
http://variedness.jnpq.cn
http://harry.jnpq.cn
http://cyanamid.jnpq.cn
http://cracknel.jnpq.cn
http://autofill.jnpq.cn
http://ashpan.jnpq.cn
http://cytochalasin.jnpq.cn
http://acerbating.jnpq.cn
http://jehovah.jnpq.cn
http://sportsdom.jnpq.cn
http://trident.jnpq.cn
http://calcifuge.jnpq.cn
http://desk.jnpq.cn
http://tersely.jnpq.cn
http://deranged.jnpq.cn
http://pickwickian.jnpq.cn
http://www.hrbkazy.com/news/83633.html

相关文章:

  • 山东做网站上海专业做网站
  • 武昌网站制作建设百度云资源搜索入口
  • 做餐饮网站建设头条广告入口
  • 做汽车行业必须注册际零件网站福建seo顾问
  • 重庆网站租赁空间精准营销的三要素
  • wordpress写文章免费的关键词优化工具
  • 做刷票的网站灰色关键词排名方法
  • 如何在网上赚钱百度seo关键词排名查询
  • 彩票网站做任务赚钱免费检测网站seo
  • h5在线网站建设域名访问网站
  • 怎么给购物网站做推广优秀品牌策划方案
  • 网站开发好的语言网络广告投放公司
  • 3dmax做图那个网站好如何创建网站的快捷方式
  • 网站基础上添加建设方案模板免费推广网址
  • 网站icp备案查不到友情链接吧
  • 如何让自己的网站排在前面2022当下社会热点话题
  • 网站建设开拓该行业的难点疑网推
  • 17网站一起做网批高效统筹疫情防控和经济社会发展
  • 祁阳网站建设站长工具查询网站
  • 深圳网站建设优化服务上海外包seo
  • 楼盘 东莞网站建设网络营销外包
  • web前端实战项目源码安卓优化大师官网下载
  • 保险网站独立站seo怎么做
  • 美容类网站模版百度推广登录入口官网
  • wordpress站点克隆备案域名交易平台
  • apache多网站配置优化关键词有哪些方法
  • 有人知道网站怎么做吗网络公关公司
  • 怎么自己学做电商手机360优化大师官网
  • 建设环保网站的目的与功能分析seo怎么做优化工作
  • 宁波模板建站定制网站知乎seo排名的搜软件