Summary_javascript实现个人简历上传照片

<html>
<head>
    <style>
        input{
            border: 0px;
            outline:none;
            height: 50px;
            text-align: center;
            font-size: 16px; font-family: "Microsoft YaHei";
        }
        textarea{
            border:0px;
            outline:none;
            text-align: left;
            font-size: 16px; font-family: "Microsoft YaHei";
        }
        table{
            border-color: black;
            border-collapse: collapse;
            text-align: center;
        }
        tr{
            border: 0px;
        }
        td{
            text-align: center;
        }
        pre{
            font-size: 16px; font-family: "Microsoft YaHei";
        }
        form img {
            height: 140px;
            width: 100px;
        }
        label{
            background-color: gainsboro;
            padding: 5px 10px;
            border-radius: 5px;
            border: 1px ridge black;
            font-size: 0.8rem;
            height: auto;
        }
        label.pos_abs{
            position:absolute;
            left: 953px;
            top: 225px;
        }
    </style>
    <title>个人简历</title>
 
</head>
<body>
 
<form action="" method="post">
    <h3 align="center">个人简介</h3>
    <table  border="1" align="center" rules=none cellspacing=0 >
        <tr>
            <td border="0">
                <table border="1">
                    <tr>
                        <td width="100" height="50">姓名</td>
                        <td height="50"><input type="text" name="name" style="width: 100px" value="小丸子"></td>
                        <td width="100" height="50">性别</td>
                        <td height="50"><input type="text" name="sex" style="width: 100px" value="女"></td>
                        <td width="100" height="50">出生年月</td>
                        <td height="50"><input type="text" name="birthday" style="width: 100px" value="1998/10/15"></td>
                        <td rowspan="4" colspan="1"  width="50">
                            <div class="preview">
                                <p>未上传证件照...</p>
                            </div>
                            <div>
                                <label class="pos_abs" for="uploadPhoto" style="">上传证件照</label>
                                <input type="file" style="width: 107px" id="uploadPhoto" class="uploadPhoto" name="photo" accept=".jpg, .jpeg, .png" style="opacity: 0">
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td width="100" height="50">民族</td>
                        <td height="50"><input  type="text" name="nation" style="width: 100px" value="汉"></td>
                        <td width="100" height="50">政治面貌</td>
                        <td height="50"><input type="text" name="politicsStatus" style="width: 100px" value="共青团员"></td>
                        <td width="100" height="50">身高</td>
                        <td height="50"><input type="text" name="height" style="width: 100px" value="1xxcm"></td>
                    </tr>
                    <tr>
                        <td width="100" height="50">学制</td>
                        <td height="50"><input type="text" name="lengthOfSchooling" style="width: 100px" value="4"></td>
                        <td width="100" height="50">学历</td>
                        <td height="50"><input type="text" name="educationBackground" style="width: 100px" value="本科"></td>
                        <td width="100" height="50">户籍</td>
                        <td height="50"><input type="text" name="censusRegister" style="width: 100px" value="安徽"></td>
                    </tr>
                    <tr>
                        <td width="100" height="50">专业</td>
                        <td height="50"><input type="text" name="major" style="width: 100px" value="CS"></td>
                        <td width="160" height="50" colspan="2">毕业学校</td>
                        <td height="50" colspan="2"><input type="text" name="graduateSchool" width="300" value="南昌大学"></td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    
</form>
<script>
    var input = document.querySelector('#uploadPhoto');
    var preview = document.querySelector('.preview');<!--获取第一个元素-->
	
    input.style.opacity = 0;
    input.addEventListener('change', updateImageDisplay);
    
	function updateImageDisplay() {
        while(preview.firstChild) {
            preview.removeChild(preview.firstChild);
        }
        var curFiles = input.files;
        if(curFiles.length === 0) {
            var para = document.createElement('p');
            para.textContent = 'No files currently selected for upload';
            preview.appendChild(para);
        } else {
            var list = document.createElement('dl');
            preview.appendChild(list);
            for(var i = 0; i < curFiles.length; i++) {//curFiles[i].name
                var listItem = document.createElement('dt');
                var image = document.createElement('img');
                image.src = window.URL.createObjectURL(curFiles[i]);
                listItem.appendChild(image);//图片
                list.appendChild(listItem);
            }
        }
    }
</script>
</body>
</html>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值