when i am trying to upload excel sheet and process each row store it on my db. unfortunately this is not working when i am uploading larger data set. same file is uploading twice. here is same code snippet.
ignore_user_abort(true);
$excelSheetReader = new Spreadsheet_Excel_Reader();
$excelSheetReader->read($_FILES['bulk_data']['tmp_name']);
$sheets = $excelSheetReader->sheets;
if(count($sheets)>0){
$sheets=$sheets[0];
}
if($sheets !=NULL) {
for ($x = 1; $x <= $sheets['numRows']; $x++) {
set_time_limit(0);
//process each row
}
}`
`
The first possible cause to check is if the users actually are uploading the files twice. :) You should make sure users aren't accidentally uploading the file multiple times, for example by clicking "submit" twice.
If user error isn't the problem, then the next thing to look at is request type. What kind of request are you using to upload the file: PUT
or a POST
? A PUT
is idempotent, which means the user's browser can repeat the request automatically if it hits an error, like timeout. POST
, however, will never be retried without asking the user first.
If you're using a PUT
, I'd suggest that you try changing the request type to POST
and see if that helps.