You can use the following, the $path should be an absolute path to a local file.
$file = new \Illuminate\Http\File($path);
$file->move();
$file->extension();
I've got image imports working nicely via an HTTP controller, as per many examples. But now I want to do the same thing to import arbitrary files from a local file system via an artisan command, where a file path is passed as an argument. In a controller I can get a handle on an uploaded file using $image = $request->file('image');, and this supports many useful things (like move(), getClientOriginalExtension()), but it seems to be specific to an uploaded file, not just a local file.
What's the right way to create an instance with similar abilities that represents a local file rather than an uploaded one?
Alternatively, how could I call my controller's store() method from artisan with the local image attached?
You can use the following, the $path should be an absolute path to a local file.
$file = new \Illuminate\Http\File($path);
$file->move();
$file->extension();
Please or to participate in this conversation.