Advertisement
Guest User

Untitled

a guest
Jul 29th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. <form action="">
  2. <input type="file" value="Add new image" id="addPhoto">
  3. </form>
  4.  
  5. <ul class="list">
  6. <li><img src="http://https://blog.shareaholic.com/wp-content/uploads/2015/06/shortlink.png" alt="" class="image"></li>
  7. <li><img src="http://http://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.png?v=c78bd457575a" alt="" class="image"></li>
  8. </ul>
  9.  
  10. function changePhoto(input) {
  11. if (input.files[0]) {
  12. var reader = new FileReader();
  13. reader.onload = function (e) {
  14. var source = e.target.results;
  15. $(".list").append("<li><img src="+source+"></li>")
  16. }
  17. reader.readAsDataURL(input.files[0]);
  18. }}
  19.  
  20. $("#addPhoto").change(function()
  21. changePhoto(this);
  22. })
  23.  
  24. .image {
  25. height: 100px;
  26. width: 100px;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement