phplaravelfile-upload

Image and images upload on laravel doesn't work online using laravel 6


i finished my project, i host it on line, i want to upload my images, on local it works fine, but online it adds root link to the database but it does not transfer the images to the root aswakfolder / public / storage / profiles / October 2020 then images are not displayed.

 if($request->hasFile('image'))
       {
        $image = $request->file('image'); 
        $imagee = md5($image);
        $image->storeAs("public\profiles\\".$jdate->format('F').$jdate->year,$imagee.'.'.$image->extension());
        $user->image = "public\\profiles\\".$jdate->format('F').$jdate->year."\\".$imagee.'.'.$image->extension(); 
        }
        $im = $user->image;  
        //images
        $dataim = array();
         if($request->hasFile('images')) 
         {
            foreach($request->file('images') as $file) 
            {
                $namee = md5($file->getClientOriginalName()).'.'.$file->extension();
                //$name = encrypt($namee).'.'.$file->extension();
                $name = "public\profiles\\".$jdate->format('F').$jdate->year."\\".$namee;
                $file->storeAs("public\\profiles\\".$jdate->format('F').$jdate->year, $namee);
                //$Annonce->images = "annonces\\".$jdate->format('F').$jdate->year."\\".time().'.'.$image->extension();  
                array_push($dataim,$name);
            } 
         }

Solution

  • Without terminal, you can create symbolic link with Route, run it once & delete it.

    route/web.php :

    Route::get('/sym', function () {
        Artisan::call('storage:link');
    });