How do I set a different route helpers public_html () from laravel in laravel 5.1?

3

Good guys, the problem is this, I try to save an image file in the public folder of a hosting, which I modified, but it does not save the image where I need it, what I have done is the following:

In the hosting I have the public folder called: carpeta.com , here I save what contains the public folder, and all the other files I keep in another folder called carpeta .

I already made the changes in the index.php so that it loads the autoload.php of boostraps.php and the project works correctly, the problem is when I try to store the image, since I create the directory public / images_events / in the carpeta and not in carpeta.com which is the public.

The way I keep the image is as follows:

In the model:

 public function setImgAttribute($img){
    if (!empty($img)) {
    $name = Carbon::now()->second.$img->getClientOriginalName();
    $this->attributes['img'] = $name;
    \Storage::disk('local')->put($name, \File::get($img)); 
    }

}

And in the Storage of filesystem.php I have this:

 'disks' => [

    'local' => [
        'driver' => 'local',
        'root'   => public_path('images_events'),
    ],

Locally it works perfectly for me, but the problem is that when I create in the hosting, it does not store the image in carpeta.com , but it creates the folder public/images_events and there is where it stores the image. I have tried placing in the index.php:

$app->bind('path.public', function() {
    return __DIR__;
});

In the register method of AppServiceProvider:

$this->app->bind('path.public', function() {
        return base_path().'/../carpeta.com/';
    });

o:

$this->app->bind('path.public', function() {
            return base_path().'/carpeta.com/';
        });

And nothing, if anyone has an idea of what he could do, I would appreciate it!

    
asked by Susje 12.08.2017 в 18:01
source

1 answer

1

As you describe the problem, the solution should be to use base_path() instead of public_path() in the filesystem configuration:

'local' => [
    'driver' => 'local',
    'root'   => base_path('images_events'),
],
    
answered by 16.08.2017 / 04:06
source