Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Laravel Read CSV File

 if (!empty($request->files) && $request->hasFile('csv_file')) {
                $file = $request->file('csv_file');
                $type = $file->getClientOriginalExtension();
                $real_path = $file->getRealPath();
                if ($type <> 'csv') {
                    Alert::error('Wrong file extension', 'Only CSV is allowed')->persistent('close');
                    return redirect()->back();
                }
                $data = $this->readCSV($real_path, array('delimiter' => ','));
            }
Comment

laravel import data from csv

function csvToArray($filename = '', $delimiter = ',')
{
    if (!file_exists($filename) || !is_readable($filename))
        return false;

    $header = null;
    $data = array();
    if (($handle = fopen($filename, 'r')) !== false)
    {
        while (($row = fgetcsv($handle, 1000, $delimiter)) !== false)
        {
            if (!$header)
                $header = $row;
            else
                $data[] = array_combine($header, $row);
        }
        fclose($handle);
    }

    return $data;
}
Comment

PREVIOUS NEXT
Code Example
Php :: newrelic apache virtual hosts 
Php :: How To Substract And Add Hours In Laravel Using Carabon? 
Php :: php check timeout 
Php :: laravel vu3 
Php :: laravel notion require 
Php :: user ,role ,permission customize laravel application 
Php :: Shorten long numbers to K/M/B? 
Php :: test php for errors terminal 
Php :: curl multi exec get index 
Php :: php expire session for 1 month 
Php :: back to same page after changing locale 
Php :: foreach loog in php 
Php :: Adding another return message from Laravel Livewire 
Php :: generate hash password in laravel online 
Php :: install php 5.5 ubuntu 20.05 
Php :: laravel media library regenerate 
Php :: pass address of array in php 
Php :: get pivot id laravel 
Php :: vagrant no pg_hba.conf entry for host 
Php :: laravel sintax 
Php :: Class PHPUnit_Util_Log_TeamCity does not exist 
Php :: WordPress Emojis abschalten 
Php :: evaluate home tilde ~ in php 
Php :: how to convert number into million and billion suffix in PHP using brick/Money package 
Php :: salom 
Php :: laravel add model to one to many relationship 
Php :: fuelphp authentication 
Php :: codeigniter sanitize array in php 
Php :: laravel eloquent save method return value 
Php :: cách nhúng php vào html 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =