Visualizzazione dei risultati da 1 a 7 su 7

Visualizzazione discussione

  1. #5
    Nelle mie ricerche ho trovato questo esempio, a me basta splittare una volta raggiunti i 16 Mb e non capisco come fare:

    codice:
    <style>
      #byte_content {
        margin: 5px 0;
        max-height: 100px;
        overflow-y: auto;
        overflow-x: hidden;
      }
      #byte_range { margin-top: 5px; }
    </style>
    
    <input type="file" id="files" name="file" /> Read bytes: 
    <span class="readBytesButtons">
      <button data-startbyte="0" data-endbyte="4">1-5</button>
      <button data-startbyte="5" data-endbyte="14">6-15</button>
      <button data-startbyte="6" data-endbyte="7">7-8</button>
      <button>entire file</button>
    </span>
    <div id="byte_range"></div>
    <div id="byte_content"></div>
    
    <script>
      function readBlob(opt_startByte, opt_stopByte) {
    
        var files = document.getElementById('files').files;
        if (!files.length) {
          alert('Please select a file!');
          return;
        }
    
        var file = files[0];
        var start = parseInt(opt_startByte) || 0;
        var stop = parseInt(opt_stopByte) || file.size - 1;
    
        var reader = new FileReader();
    
        // If we use onloadend, we need to check the readyState.
        reader.onloadend = function(evt) {
          if (evt.target.readyState == FileReader.DONE) { // DONE == 2
            document.getElementById('byte_content').textContent = evt.target.result;
            document.getElementById('byte_range').textContent = 
                ['Read bytes: ', start + 1, ' - ', stop + 1,
                 ' of ', file.size, ' byte file'].join('');
          }
        };
    
        var blob = file.slice(start, stop + 1);
        reader.readAsBinaryString(blob);
      }
      
      document.querySelector('.readBytesButtons').addEventListener('click', function(evt) {
        if (evt.target.tagName.toLowerCase() == 'button') {
          var startByte = evt.target.getAttribute('data-startbyte');
          var endByte = evt.target.getAttribute('data-endbyte');
          readBlob(startByte, endByte);
        }
      }, false);
    </script>
    Ultima modifica di ciro78; 03-05-2020 a 10:36 Motivo: tag code

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.