mardi 28 août 2018

Laravel Out of memory on localhost when trying to upload very big file

I am trying to upload csv file so that I can upload those data into the database. The code for the same is as bellow

public function upload(Request $request){
        set_time_limit(0);
        ini_set('MAX_EXECUTION_TIME', 36000);
        $file = Input::file('file');
        $filePath = $file->getRealPath();

       $handle = fopen($filePath, "r");
        while(!feof($handle))
        {
           << DO THE DATABASE OPERATION >>
        }
        fclose($handle);

  return redirect()->back()->with('success', 'File uploaded successfully');
}

This works fine if the file size is less lets say about 100 or 200mb. But when the file size is big like 2GB. It closes the local server. In the console, it says out of memory

My php.ini settings are :

post_max_size=10000M
upload_max_filesize=10000M

Can anyone please tell me why this is happening and how can i fix it. I did follow a couple of threads on StackOverflow like this

phpMyAdmin: Can't import huge database file, any suggestions?

Large file uploads failing php

Laravel out of memory issue?

But unfortunately, these solutions did not help.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2BWHCV8
via IFTTT

Aucun commentaire:

Enregistrer un commentaire