1

I am working on a project in which i want to get the link of the file which i uploaded in the storage-app-public directory of laravel. I followed this link StackOverflow question, but when I try to run following command in Vagrant:

php artisan storage:link

It gives following error:

[Symfony\Component\Console\Exception\CommandNotFoundException]
There are no commands defined in the "storage" namespace.
Troyer
  • 6,765
  • 3
  • 34
  • 62
shahzeb akram
  • 906
  • 7
  • 24

1 Answers1

0

you need to follow this code, I think It will be helpful for you.

$imageTempName = $userdata->file('image_media')->getPathname();
$imageName = $userdata->file('image_media')->getClientOriginalName();

upload the file to the database within the directory using Laravel.

<?php
public static function upload_file(Request $userdata){
    $imageTempName = $userdata->file('image_media')->getPathname();
    $imageName = $userdata->file('image_media')->getClientOriginalName();
    $path = base_path() . '/public/uploads/images/';
    $userdata->file('image_media')->move($path , $imageName);
    $data=array('media'=>$imageName);
    $insert=with(new UserModel)->uploadFile($data);
}
?>
Flexo
  • 87,323
  • 22
  • 191
  • 272