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 :: laravel gigapay get single payout 
Php :: Laravel array to string error 
Php :: fetch email from url contact form 7 
Php :: extract date from datetime object in php 
Php :: eloquent search from child table column 
Php :: checks whether the session is set or not, if not it will redirect the user to login page. 
Php :: laravel select error 
Php :: 150 charachter display only php 
Php :: Relationship 1-n multiple BACKPACK Laravel 
Php :: amazon linux 2 php.ini changes not working 
Php :: php Display random custom content in WooCommerce shop archive loop 
Php :: selecting a time zone from a drop-down list 
Php :: php know if city exist gmap api 
Php :: Binance api buymarket php 
Php :: Delete Collection (Get) 
Php :: php parse_url array function 
Php :: termii curl otp 
Php :: x-default wpml canonical alternate hreflang 
Php :: how to know app_basepath 
Php :: mr deepfakes forum 
Php :: wpmu assign user to blog 
Php :: how to override category product from seo title and description 
Php :: codeigniter round off function 
Php :: Pasar el email de recuperar contraseña de laravel a español 
Php :: how to upload images to sql database php PDO 
Php :: codeigniter base url automatic 
Php :: how to implement email verification in laravel 
Php :: how to append one array to another array in php 
Php :: how to convert youtube video to mp3 in php 
Php :: dateinterval hh mm ss 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =