hasFile('csv')) { Session::flash('warning', 'No file uploaded.'); return Redirect::route('csv.index'); } $hasHeaders = intval(Input::get('has_headers')) === 1; $reader = Reader::createFromPath($request->file('csv')->getRealPath()); $data = $reader->query(); $data->next(); // go to first row: $count = count($data->current()); $headers = []; for ($i = 1; $i <= $count; $i++) { $headers[] = trans('firefly.csv_row') . ' #' . $i; } if ($hasHeaders) { $headers = $data->current(); } // example data is always the second row: $data->next(); $example = $data->current(); // store file somewhere temporary (encrypted)? $time = str_replace(' ', '-', microtime()); $fileName = 'csv-upload-' . Auth::user()->id . '-' . $time . '.csv.encrypted'; $fullPath = storage_path('upload') . DIRECTORY_SEPARATOR . $fileName; $content = file_get_contents($request->file('csv')->getRealPath()); $content = Crypt::encrypt($content); file_put_contents($fullPath, $content); Session::put('latestCSVUpload', $fullPath); $subTitle = trans('firefly.csv_process'); return view('csv.upload', compact('headers', 'example', 'roles', 'subTitle')); } }