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 list invoice 
Php :: codeigniter query Profiling 
Php :: Laravel Query: orderBy not working with groupBy (with a joined table) 
Php :: ganti url phpmyadmin 
Php :: webiste url filter with pregx 
Php :: php: Güvenlik Fonksiyonu 
Php :: Drupal 9 check if UUD is valid 
Php :: how to read laravel query string with dash 
Php :: php random string for filename 
Php :: upload video file in mysqli using php 
Php :: php artisan reset --force 
Php :: remove nul value aray php 
Php :: Add ACF to single.php 
Php :: symfony user online 
Php :: search a file name and open that file phpstrom 
Php :: show all custom taxonomy term & title with filter hook 
Php :: php remove new line character from string 
Php :: export csv file in laravel 
Php :: Deprecated: WC_Product::get_dimensions error fix 
Php :: required if null / require without laravel 
Php :: numeros positivos input laravel 
Php :: cashier mollie 
Php :: remove public from laravel url live 
Php :: Regenerate session ID and remove all session data 
Php :: php validation form 
Php :: if product open display this button 
Php :: Max() Value And Min() Value 
Php :: php count result query 
Php :: php base64 encode utf8 
Php :: remove public from laravel url 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =