JSDM

HTML

 
1
<!DOCTYPE html>
You don't need a DOCTYPE on CodePen. Just put here what you would normally put in the <body>.
2
<html lang="en">
3
  <head>
4
    <meta charset="UTF-8">
5
    <title>拍照</title>
6
    <style type="text/css">
7
      img {
8
        border: 1px solid #ccc;
9
        min-width: 100px;
10
        min-height: 100px;
11
      }
12
    </style>
13
  </head>
14
  <body>
15
    <p>上传区</p>
16
    <input name="files" type="file" accept="image/*" onchange="preview(this)" />
17
    <p>预览区</p>
18
    <img src="" id="img">
19
    <script>
20
      function preview(input) {
21
        var url = '';
22
        //预览路径
23
        if (window.createObjectURL != undefined) {
24
          url = window.createObjectURL(input.files[0]);
25
        } else
26
        if (window.URL != undefined) {
27
          url = window.URL.createObjectURL(input.files[0]);
28
        } else
29
        if (window.webkitURL != undefined) {
30
          url = window.webkitURL.createObjectURL(input.files[0]);
31
        }
32
        document.getElementById('img').src = url
33
      }
34
    </script>
35
  </body>
36
</html>
37
!

CSS

xxxxxxxxxx
1
 
1
? ?
? ?
必须是有效的URL
+ 添加另一个资源

JS

xxxxxxxxxx
1
 
1
必须是有效的URL
+ 添加另一个资源
Close

文件管理 点击文件查看URL

图片

  1. 暂无文件

CSS

  1. 暂无文件

JavaScript

  1. 暂无文件

其他

  1. 暂无文件
拖动文件到上面的区域或者:
加载中 ..................