Alica_Selezneva's avatar

Upload file thought the artisan command

Hi guys, I have a test assigment , and one of reqiurments is : Using Laravel create an Artisan command that accepts two arguments - "path_to_file" and "id". The command should parse the attached file that has a fixed width text format and import the data into a mysql database.

I don't have any problems with parsing and saving data, but I stucked on Laravel file system and can't understand how to import a file to the command if it not in the storage. Please help

0 likes
2 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

You give it a path to a file, and then do something with it?

\Illuminate\Support\Facades\File::move($path, '/newpath');
//or if you need to work with the file
$fileContents = \Illuminate\Support\Facades\File::get($path);

Please or to participate in this conversation.