Laravel-excel: file not found after upload

Created on 14 Feb 2019  路  4Comments  路  Source: Maatwebsite/Laravel-Excel

Prerequisites

-->

  • [ ] Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • [ ] Checked that your issue isn't already filed.
  • [x] Checked if no PR was submitted that fixes this problem.

Versions

  • PHP version: 7
  • Laravel version: 5.5
  • Package version: 3.1

Description

Hi
$path = $request->file('import_file')->getRealPath(); Excel::import(new importCommissionBatch($data->id), $path);
after use this code with upload file excel it return

League \ Flysystem \ FileNotFoundException
File not found at path: D:/xampp/tmp/php4372.tmp

Steps to Reproduce

Expected behavior:

Actual behavior:

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

Most helpful comment

You have to either upload the uploaded file to a disk or pass the uploaded file directly.

Example:
Excel::import(new importCommissionBatch($data->id), $request->file('import_file'));

All 4 comments

You have to either upload the uploaded file to a disk or pass the uploaded file directly.

Example:
Excel::import(new importCommissionBatch($data->id), $request->file('import_file'));

thanks work fine but have another error

<?php

namespace App\excel;

use App\commission;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
use Jalalian;
use Maatwebsite\Excel\Facades\Excel;
use Webine\Base\Helpers\convert_date;

class importCommissionBatch implements ToModel,WithHeadingRow,WithMultipleSheets
{
    protected $batch_id;

    public function __construct($batch_id = 1)
    {
         $this->batch_id = $batch_id; 
    }

    public function model(array $row)
    {
        if($row['amount'] && $row['user_id']) return new commission([
            'batch_id'=>$this->batch_id,
            'user_id'=>$row['user_id'],
            'amount'=>$row['amount'],
            'is_active'=>1,
            'date_at'=>convert_date::to_gregorian($row['date_at_jalali']),
            'date_jalali_at'=>$row['date_at_jalali'],
        ]);
    }

    public function sheets(): array
    {
        return [
            // Select by sheet index
            0 => new importCommissionBatch(),
        ];
    }
}

Start row (2) is beyond highest row (1)
image

Start row (2) is beyond highest row (1)
image

Please read https://github.com/Maatwebsite/Laravel-Excel/issues/1889 and https://github.com/Maatwebsite/Laravel-Excel/issues/1904 first.

Might be something wrong with your file.

You have to either upload the uploaded file to a disk or pass the uploaded file directly.

Example:
Excel::import(new importCommissionBatch($data->id), $request->file('import_file'));

your solutions helps me a lot

Was this page helpful?
0 / 5 - 0 ratings