javascript - How to set up HTML Local Storage for an image/ this? -


so how set html local session storage this:

<form id="form1" runat="server">     <input type='file' id="imginp" />     <br>     <img id="blah" src="" alt="upload image" />       <img id="blah2" src="" alt="upload image" />       <img id="grooved" src="https://lh3.googleusercontent.com/-6wxp99pr7hu/vpa-nidksdi/aaaaaaaamka/r59f0in-yya/s800-ic42/grooved%252520view%252520for%252520shopify.png" alt="your image" height="100" /> </form>      <br/>     <div id="nofileerror" style="display:none;">         <b>please select valid image file.</b>     </div>     <button id="checkimage" style="display:none;"> check image </button>     <br/>     <b>resolution check result: </b>   <p>if nothing displayed underneath means image top quality , ready printing!</p>     <p>      </p>     <div id="imagevalidationerror" style="display:none;">         <b id="lr">unfortunatley image resolution low our pixboards, may still proceed using image cannot guarentee great resolution! proceeding image you're agreeing , aknowladge resolution not high standards advertised.</b>     </div>     <style>      #lr {      color: red;      }  ::-webkit-scrollbar-track {     -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.2);      background-color: #f5f5f5; }  ::-webkit-scrollbar {     width: 6px;     background-color: #f5f5f5; }  ::-webkit-scrollbar-thumb {     -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.2);     background-color: #555; }  #blah {  width:550px;    height:550px;   background-image: url('path/to/image');   background-position: center;   background-size: cover; }  #blah2 {  width:550px;    height:550px;   background-image: url('path/to/image');   background-position: center;   background-size: cover;   position: absolute; }  #grooved {   width: 550px;   height: 550px;   position: absolute;   top: auto 0; }   </style>    <script>        function readurl(input) {         if (input.files && input.files[0]) {             var reader = new filereader();              reader.onload = function (e) {                 $('#blah').attr('src', e.target.result);             }              reader.readasdataurl(input.files[0]);                     isgoodimage(input.files[0])         }     }      $("#imginp").change(function(){         readurl(this);     });       function readurl2(input) {         if (input.files && input.files[0]) {             var reader = new filereader();              reader.onload = function (e) {                 $('#blah2').attr('src', e.target.result);             }              reader.readasdataurl(input.files[0]);         }     }      $("#imginp").change(function(){         readurl2(this);     });      var _url = window.url || window.webkiturl;  function issupportedbrowser() {     return window.file && window.filereader && window.filelist && window.image; }  function getselectedfile() {     var fileinput = document.getelementbyid("imginp");     var fileisselected = fileinput && fileinput.files && fileinput.files[0];     if (fileisselected)         return fileinput.files[0];     else         return false; }  function isgoodimage(file) {     var deferred = jquery.deferred();     var image = new image();      image.onload = function() {         // check if image bad/invalid         if (this.width + this.height === 0) {             this.onerror();             return;         }          // check image resolution         if (this.width >= 3000 && this.height >= 2000) {             deferred.resolve(true);         } else {             $("#imagevalidationerror").show();             deferred.resolve(false);         }     };      image.onerror = function() {         $("#nofileerror").show();         deferred.resolve(false);     }      image.src = _url.createobjecturl(file);      return deferred.promise(); }  /** new code **/     $("#checkimage").click(function(){         if (issupportedbrowser()) {            var file = getselectedfile();           if (!file) {               $("#nofileerror").show();               return;           }            isgoodimage(file)       }     })   </script> 

basically image resolution checker customer can check resolution of image , proceed cart if correct resolution need when upload image there displayed in cart on next page ? appreciated, thank you!


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -