Jorden vg
Jorden vg

Reputation: 845

Laravel file uploading goes wrong when I remove the quicklink to the storage/images folder

I have a problem with fileuploading(images). my script somehow can read my articles and put them on the show page but doesn't want to insert the images into the folder.

Everything in the database works fine, you can see everything getting submitted but when inserting images into the storage/cover_images folder it doesn't put them inside. after I removed the quick link(PHP artisan storage:link) to the storage folder it didn't work anymore. I can't add it back because I work with colleagues who pull the project from GitHub and the quick links are local so otherwise, it will only work on my computer.

TO BE CLEAR:

The only thing i want is that my images will be inserted into the public/storage/cover_images folder.

my site doesnt give back errors and inserts everything into the database. the only thing that needs to be fixed is my images into the public/storage/cover_images folder.

in my ArticleController:

public function update(Request $request)
{

    if($request->hasFile('cover_image')){

        $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); 

        $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);

        $extension =  $request->file('cover_image')->getClientOriginalExtension();

        $fileNameToStore = $filename . '_' . time() .'.'. $extension;

        $path = $request->file('cover_image')->storeAs('/public/storage/cover_images', $fileNameToStore);

    }else{

        $fileNameToStore = 'noimage.jpg';

    }

show.blade.php(which works fine):

<div class="row">
            <div class="artikelfoto marginauto col-md-6 offset-md-3 mt-3 mb-3">
            <img class="img-fluid" src="/storage/cover_images/{{$artikel->cover_image}}" style="width:100%">
                <p style="font-size:.75em; color:#b4b4b4">{{$artikel->source}}</p>
            </div>

the public folder with paths:

enter image description here

database(you can see everything gets inserted):

enter image description here

does anyone faced this problem before? any help is appreciated!

Upvotes: 0

Views: 115

Answers (1)

Akash Kumar Verma
Akash Kumar Verma

Reputation: 3328

if you don't have ssh access then simply create a route.so you can hit this command simply by hitting url

Route::get('/artisan/storage', function() {
    $command = 'storage:link';
    $result = Artisan::call($command);
    return Artisan::output();
})

Upvotes: 1

Related Questions