jeudi 3 janvier 2019

How to get the actual file after being uploaded in Laravel?

Here is how I am uploading the file via my view derived from HomeController@index:

<form action='csvUpload' method='POST'>
    @csrf
    <input type='file' name='dataframe' enctype="multipart/form-data">
    <button type='submit' name='upload'>Predict</button>
</form>

Here is my web routes:

Auth::routes(['verify' => true]);

Route::get('/home', 'HomeController@index')->name('home');
Route::post('/csvUpload', 'HomeController@predict')->name('home');

Here is my HomeController@predict:

public function predict(Request $request)
{   
    $file = $request->dataframe;
    var_dump($file); # I want this to be the actual file or
                     # To store it locally and then get that file path
}

Which is returning string(13) "languages.csv" when I upload my CSV file. How can I get the actual file? I have tried $request->file('dataframe') but that returns null.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire