上传头像

简单的上传头像静态页面

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
    <head> 
        <title>tupian</title> 
        <style> 
 .white_content { 
          
            position: absolute; 
display:none;
            top: 25%; 
            left: 35%; 
            width: 632px; 
            height: 494px; 
            padding: 20px; 
            border: 1px solid #adacac; 
            background-color: white; 
            z-index:1002; 
            overflow: auto; 
        } 
    .sj_con {
padding: 0px;
height: 460px;
width: 600px;
margin-top: 10px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 15px;
 
}
.sctp{width:500px; height:40px;}
.uploadfile{width:132px;}
.input-file{display: inline-block;width: 130px;font-size: 18px;line-height: 37px;height: 40px;text-align: center; overflow: hidden;position: relative;background: #2FA8E6;color: #fff; transition:background .3s;-webkit-transition:background .3s}/*自定义外框样式*/
 .input-file input{opacity: 0;filter:alpha(opacity=0);font-size: 100px;position: absolute;top: 0;right: 0} /*隐藏默认控件样式*/


 
.scgs {
font-size: 14px;
line-height: 40px;
color: #666;
text-align: left;
padding: 0px;
height: 43px;
width: 500px;
margin-top: 10px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 20px;
}
.ig {
padding: 0px;
height: 250px;
width: 600px;
margin-top: 20px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #CCC;
}
.txdx {
margin: 0px;
padding: 0px;
float: left;
height: 200px;
width: 200px;
border: 1px solid #FF0;
}
.txdx1 {
padding: 0px;
float: left;
height: 150px;
width: 150px;
border: 1px solid #FF0;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 30px;
}
  .seltt {
height: 50px;
width: 214px;
margin-top:25px;
float:left;
padding: 0px;
margin-right: 0px;
margin-bottom: 10;
margin-left: 380px;
}
.lfbt {
font-size: 14px;
line-height: 25px;
color: #FFF;
background-color: #009ddc;
text-align: center;
float: left;
height: 25px;
width: 100px;
}
.lfbt a {
color: #FFF;
text-decoration: none;
}
</style> 
    </head> 
    <body> 
        <p>示例弹出层:<a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">请点这里</a></p> 
         <div id="light" class="white_content"> 
          <div class="sj_con">
 <div class="sctp">
  <form action=" " enctype="multipart/form-data" method="post" class="uploadfile"><label class="input-file"><input title="浏览文件" type="file" name="file">上传图片</label><input type="hidden" name="id" value="104"></form>
  </div>
<div class="scgs">仅支持JPG,PNG,GIF格式,文件小于5M</div>
<div class="ig">
  <div class="txdx"></div>
  <div class="txdx1"></div>
</div>
 
<div class="seltt">
  <div class="lfbt"><a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">提交</a></div>
  <div class="lfbt" style="float:right;"><a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">取消</a></div>
</div>
  </div>
 </div> 
        <div id="fade" class="black_overlay"></div> 
    </body> 
</html>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Element Plus 是 Vue 3 的 UI 组件库,它提供了一个简洁易用的界面构建工具。关于上传头像的功能,Element Plus 的 `el-upload` 组件可以用来实现图片上传。以下是一个基本的使用步骤: 1. 引入组件:首先,你需要在你的项目中安装并引入 `ElUpload` 组件。在你的入口文件或组件的 `import` 块中添加: ```js import { ElUpload } from 'element-plus'; ``` 2. 定义组件:在模板中使用 `ElUpload`,设置一些基本配置,如上传按钮、上传路径、文件格式等: ```html <el-upload :action="uploadUrl" // 你的服务器接收图片的URL :on-change="handleChange" // 上传成功后的回调 :file-list="fileList" // 存储已选择文件的列表 :accept="'.jpg, .png'" // 可接受的文件类型 :auto-upload="false" // 是否自动上传,通常为 false,以便于控制 > <el-button slot="trigger">选择图片</el-button> <div slot="tip">点击上传</div> </el-upload> ``` 3. 处理上传事件:在组件的 script 部分,定义 `handleChange` 方法处理文件上传和状态更新: ```js export default { data() { return { uploadUrl: 'your-api-url', // 上传到服务器的接口地址 fileList: [], // 用于存储上传的图片信息 }; }, methods: { handleChange(file) { if (file.status === 'success') { // 处理上传成功的逻辑,比如更新文件列表,显示预览等 this.fileList.push({ name: file.name, url: file.response, // 服务器返回的新图片URL thumbUrl: file.url, // 预览图URL }); } }, }, }; ``` 记得替换 `uploadUrl` 为你实际的服务器接口地址,并根据需求定制其他上传参数和回调行为。如果需要额外功能,如进度条、限制上传大小等,可以在 `el-upload` 的选项中添加相应的属性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值