Reputation: 525
I host my laravel application in a seared hosting and i upload my laravel project into the root directory and i upload my public folder into the public_html directory .
i want to save image in avater_img
or assistant_img
or doctor_img
.
For thereby i write this code
$file = Input::file('photo');
if($file != ""){
$ext = $file->getClientOriginalName();
$file_name = rand(10000,50000).'.'. $ext;
$image = Image::make(Input::file('photo'));
$image->resize(300,300);
$image->save(public_path() . '/doctor_img/' . $file_name);
}
How can i fix this error
Upvotes: 1
Views: 903
Reputation: 59
Your image path is wrong. It should be like this.
$image->save(public_path() . '../doctor_img/' . $file_name);
As public_path() goes to public folder.
Upvotes: 0
Reputation: 459
The problem is you are not using the default Laravel file structure, therefore your public_path() is still pointed into /home/dermopres/laravel/public as mentioned in the error message.
First thing that you should do is set your Laravel application according to your current file structure.
On your public_html/index.php change the following line:
require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
to
require __DIR__.'/../laravel/bootstrap/autoload.php';
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
and also add this line to the /laravel/bootstrap/app.php:
$app->bind('path.public', function() {
return __DIR__.'/../../public_html';
});
Upvotes: 1
Reputation: 950
you have to make the doctor_img directory writable
if you are on linux / homestead
run below on terminal
sudo chmod 666 -R /home/dermopres/laravel/public/doctor_img
Upvotes: 0