Click here to Skip to main content
15,890,186 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im a novice and i have been facing issues specially on IE9.
I ve been trying to find the max download and upload speed for a internet device. So for it i am downloading a data buffer and uploading a data buffer to a server.
In IE8 the following code works fine

C#
if(BrowserType=="MSIE")
    {
      xhr=new XDomainRequest();
      xhr.onerror = err;
      xhr.ontimeout = timeo;
      xhr.onprogress = progres;
      xhr.onload = loadd;
   
      xhr.timeout = 500;
    }
    else
        xhr = new window.XMLHttpRequest();
    xhr.onreadystatechange=function()
    {
        var iLen = bufferedData.length;
        if(iLen <= 100000)
          bufferedData=bufferedData+xhr.responseText;
     
    }

    xhr.open("GET", "myserverfile.php", true);
    xhr.send();

I am sending a Ajax request to the server and downloading bit of stream of file from the server as follows:



PHP
define('CHUNK_SIZE', 1024*15240); // Size (in bytes) of tiles chunk

function readfile_chunked($filename) {

echo "In ReadFile";

    $buffer='';

    $cnt=0;

    $handle=fopen($filename, 'rb');

    if ($handle===false) {

      return false;

    }

    while ($cnt!=1) {

      $buffer=fread($handle, CHUNK_SIZE);

      echo $buffer;

      ob_flush();

      flush();

      ++$cnt;

      sleep(1);
    }
   $status=fclose($handle);

    return $status;
   }
  $filename="argo.MP4";
  //echo "Before Readfile";
  readfile_chunked($filename);



The problem that i am facing is that when i give CHUNK_SIZE as 1024*15240 in IE8 i.e it downloads 1024*15240 data in say X time, it works fine but when i give the same 'CHUNK_SIZE', 1024*15240); in IE9, it doesnt download the whole data and gets stuck in the middle.
Is it because of the buffer size difference in IE8 and IE9 or is there some problem with my code. According to me i dont think there is any problem but still.

Please suggest me something through which i can move forward with IE9.
Thank you
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900