javascript - Dragging local image in webpage crashes Chrome -


I am working on a page where users can view / upload local files. Once the file is selected, I am displaying the image in the page. I have encountered a problem that crashes my browser window (chrome) by dragging this image.

Simple HTML:

& lt; Input

Javascript (jQuery):

  $ ('Input') {var file = $ ('input'). Get (0) .files ; Var fileRedder = new file reader (); fileReader.onload = function (e) {$ ('img') .attr ('src', e.target.result);}; fileReader.readAsDataURL (file [0]) ;});   

Speaking of a bit more, it seems that with big image files (such as uncompressed photos from the iPhone), this is a problem. It is not necessary that the page be a dealer-breaker, but definitely drag one image and instantly get bothered to crash the page.

Is there a good way to fix this?

Post-text "itemprop =" text "= undefined & window.phill reader! == undefined) {var reader = new FileReader (); Var self = this; Reader.odo = function (e) {if (window.Blob) {var blob = new blob ([e.target.result]); Window.URL = window.URL || window.webkitURL; Var blobURL = window.URL.createObjectURL (blob); Self.setSrc ({"tempUrl": blobURL}); // Using spinal cord refers to this one model}}; reader.readAsArrayBuffer (file); } Else {if (! File) console.error ("no file was paused"); If (! Window.FileReader) console.error ("Your browser is not supported"); }

As I could see, readAsDataURL kills memory.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -