-
Notifications
You must be signed in to change notification settings - Fork 0
/
imageupload.html
76 lines (71 loc) · 2.21 KB
/
imageupload.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Image preview</title>
<link href="css/bootstrap.css" type="text/css" rel="stylesheet" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
var blank="http://upload.wikimedia.org/wikipedia/commons/c/c0/Blank.gif";
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#img_prev').attr('src', e.target.result).height(100).width(100);
};
reader.readAsDataURL(input.files[0]);
}
else {
var img = input.value;
$('#img_prev').attr('src',img).height(200);
}
$("#x").show().css("margin-right","10px");
}
$(document).ready(function() {
/*$('#imgupload').change(function(){
var fileName = $(this).val();
if(fileName) {
$('.btn').css('background-image','url(imges/delete.png)');
$(this).click(function(){
$(this).reset();
})
}
}); */
$("#x").click(function() {
$("#img_prev").attr("src",blank);
$("#x").hide();
});
});
</script>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
#x { display:none; position:relative; z-index:200; float:right}
#previewPane { display: inline-block; }]
</style>
</head>
<body>
<div data-provides="fileupload" class="fileupload fileupload-exists">
<input type="hidden">
<div style="height: 150px; width: 200px;" class="fileupload-new thumbnail">
<img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&text=no+image">
</div>
<div style="max-width: 100px; max-height: 100px; margin: 10px 0 0 10px;" class="fileupload-preview fileupload-exists thumbnail">
<img style="height:100px; width:100px;" id="img_prev" src="#" alt="" />
</div>
<div>
<span class="btn btn-file">
<input id= "imgupload" type="file" onchange="readURL(this);">
</span>
</div>
</div>
<!-- <section>
<input type='file' id='imageupload' onchange="readURL(this);" class="noneimg" /><br/>
<span id="previewPane">
<img id="img_prev" src="#" alt="your image" />
<span id="x">[X]</span>
</span>
</section>-->
</body>
</html>