Dina Shaldoum
Dina Shaldoum

Reputation: 89

Getting image path in public folder in laravel

I'm making direction using this method to upload my image

 mkdir(public_path().'/website/'.$path,0777, true);

It's supposed to create it on the root folder (Public_html) , but i found it created on new folder with name (public ) , so now i can't get the path of the image using this code

 <img src="{{url('public/website/'.$file->path.$file->file)}}"  />

how to get the correct path of the image or even create the folder on the public_html root path ?

Upvotes: 0

Views: 15783

Answers (5)

Necare
Necare

Reputation: 1

I didn't tested it but... did you have tried this way?

mkdir(public_path('/website/'.$path),0777, true);

To me, if I'm not wrong your problem could be only a matter of writing.

Upvotes: 0

Jagdish Chaudhary
Jagdish Chaudhary

Reputation: 287

See Here for more info

You can use laravel helper function asset for eg. $url = asset('img/photo.jpg'); then you will get full path with public directory. $url return www.your.domain.com/public/img/photo.jpg

Upvotes: 0

ram pratap singh
ram pratap singh

Reputation: 53

You try this to get your image content

  <img src="<?php echo asset('/').'public/'.$path.$file->file;  ?>"  />

Upvotes: 0

Andranik Petrosyan
Andranik Petrosyan

Reputation: 92

you can use public_path(); function in laravel 
or
<img src="{{ public_path().'/website/'.$file->path.'/'.$file->file;}}"  />
or
<img src="/website/{{$file->path.$file->file}}"  />

Upvotes: 1

ram pratap singh
ram pratap singh

Reputation: 53

Try this to get image

 <img src="<?php echo public_path().'/website/'.$path.$file->file;  ?>"  />

Upvotes: 1

Related Questions