Reputation: 538
Iam Deploy my project web on shared hosting . and following tutorial to move all on the public(local) folder to public_html(hosting)
my Structure
(/home/sippausr)
laravel
logs
public_ftp
public_html ->
css
files
home
images
js
kalibrasi
public
sop
theme
and now i have a controller to send this data to folder files
My Controller
public function store6(Request $request)
{
$this->validate($request, [
]);
if($request->hasfile('image'))
{ $file = $request->file('image');
$name=$file->getClientOriginalName();
$file->move(public_path().'/files/', $name);// i think this problem on here
$data = $name;
}
$user = new pemeliharaan;
$id = Auth::user()->id;
$user->user_id = $id;
$user->alat_id = $request->alat_id;
$user->pertanyaan =json_encode($request->except
(['_token','name','alat_id','status','catatan','image']));
$user->catatan = $request->catatan;
$user->image=$data;
$user->status = $request->status;
$user->save();
// dd($user);
return redirect('user/show6')->with('success', 'Data Telah Terinput');
}
but this image cant saved at directory files . this name image is saved on database , but this file is not saved . how i can fix this ?
Upvotes: 0
Views: 1152
Reputation: 629
Perhaps you have applied a symlink
and directs you to a different folder?
Try to resolve or make sure that you are pointing to the right path first
If all else fails, you made edit your default saving folder inside the config / filesystems.php
file
Particularly this portion:
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
],
],
You may change root
keys to specifically point to your desired folder.
Since you have mentioned that you have deployed or uploaded it on a hosting, you may try this one, something I have done before and fixed the problem
'public' => [
'driver' => 'local',
//When I upload my Laravel app in a shared hosting I uncomment the code below, to specifically pinpoint to my "storage" folder of the app
'root' => '/home/w8p8r839yfqy/public_html/storage/',
//But when I continue coding locally or in my personal machine, I uncomment the code below
'root' => storage_path('../public/storage/'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
Upvotes: 0