Ayesha Fathima

Ayesha Fathima

  • NA
  • 184
  • 29.6k

Response not received in time

Mar 19 2018 6:52 AM
Hi there,
Iam trying to read file,and need to take that base64 value and pass it as input for some webservice.
While doing this process,to read the file it is taking some time.
Before reading my file it is going to further steps,and iam getting base64 value as empty.
Any suggestion is highly appreciable for me.I tried to keep timeout while reading,but it is not working.
Below is sample code
 
  1. if(input.files.length!=0)  
  2.    {  
  3.      //file = input.files[i];  
  4.   for(i=0;i<input.files.length;i++){  
  5.   var fileReader = new FileReader();  
  6.  filname=input.files[i]["name"];  
  7.    
  8.  fileReader.readAsDataURL(input.files[i]);   
  9. //setTimeout(fileReader.readAsDataURL(input.files[i]), 10000);  
  10.    
  11.  fileReadContent = fileReader.result//here it is taking time to read the file  
  12.  fileReadContent=fileReadContent.split(",");  
  13.  fileReadContent.shift();//to get base64 value  
  14.   if(fileReadContent!="")  
  15.     storecontent();  
  16.   else  
  17.     alert("Data not available")  
  18.    }   
  19.   }  
 

Answers (10)