Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>Load Image</title>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
- <script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
- <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
- <script>
- $(document).ready(function(){
- $("#uploadimage").on("change", draw);
- });
- function draw(ev) {
- console.log(ev);
- var ctx = $('#canvas')[0].getContext('2d'),
- img = new Image(),
- f = $("#uploadimage")[0].files[0],
- url = window.URL || window.webkitURL,
- src = url.createObjectURL(f);
- img.src = src;
- img.onload = function() {
- ctx.drawImage(img, 0, 0);
- url.revokeObjectURL(src);
- }
- }
- </script>
- </head>
- <body>
- <div class="container">
- <input type='file' name='img' size='65' id='uploadimage' />
- <canvas id="canvas" width="500" height="500"></canvas>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement