Aug 13, 2022
1
Level 2
all fields are updated including pdf files except images( in host server only)
Hi In my local server I have form has fields of images and files, updating them with following controller function and it is working for all of them even files and images:
public function update(Request $request, $id)
{
$cv = auth()->user()->cv;
$this->validate($request, [
'img'=>'file|mimes:jpg,bmp,png',
'Major' => 'required|max:125',
]);
$input=$request->all();
if ($image3 = $request->file('img')) {
$imageDestinationPath1 = 'uploads/images/jobs/';
$postImage3= date('YmdHis') . "." . $image3->getClientOriginalExtension();
$image3->move($imageDestinationPath1, $postImage3);
$imgpath = 'uploads/images/jobs/'.$postImage3;
$input['img'] = "$imgpath";
}
else{
unset($input['img']);
}
if ($file = $request->file('fileCV')) {
$fleDestinationPath = 'uploads/images/jobs/';
$postfile= date('YmdHis') . "." . $file->getClientOriginalExtension();
$file->move($fleDestinationPath, $postfile);
$imgpath = 'uploads/images/jobs/'.$postfile;
$input['fileCV'] = "$imgpath";
}
else{
unset($input['fileCV']);
}
if ($file1 = $request->file('AdditionDoucument')) {
$fleDestinationPath2 = 'uploads/images/jobs/';
$postfile1= date('YmdHis') . "." . $file1->getClientOriginalExtension();
$file1->move($fleDestinationPath2, $postfile1);
$imgpath = 'uploads/images/jobs/'.$postfile1;
$input['AdditionDoucument'] = "$imgpath";
}
else{
unset($input['AdditionDoucument']);
}$cv->update($input); return redirect(session('links')[0])->with('success', 'Your Application UPDATED successfully.'); // Will redirect 2 links back
}
but when I moved the same code to host server the image is not updated all other fields are updated except img, it goes to the if condition and the photo is uploading but it is not uploaded in the database I checked everything include the view :
<form action="{{route('cv.update',['id'=>$cv])}}" method="POST" enctype="multipart/form-data" id=cv style="overflow:hidden";>
@csrf
<div class="col-6">
<strong>photo<aspan class='photo';>(optionlly size should be less than 200bytes))</aspan></strong>
<input class="form-control mt-1" name="img" type="file" style="padding-top: 4px;padding: inherit;">
</div>
<div class="row ">
<div class=col-4>
<select name="MajorField" class="custom-select1">
@foreach(\App\Models\Major::all() as $catagories)
<option value="{{ old('MajorField')??$cv->MajorField }}">{{ old('MajorField')??$cv->MajorField }}</option>
<option value="{{$catagories->name}}">{{$catagories->name}}</option>
@endforeach
</select>
</div>
<div class=col-4>
<strong>Upload CV:</strong><aspan class='photo';>(size should be less than 2 MB))</aspan></strong>
<input type="file" class="form-control pb-4"value="{{ old('fileCV')??$cv->fileCV }}" name="fileCV" style=padding-top:4px; >
</div>
<div class=col-4>
<strong>Additional Document:</strong><aspan class='photo';>(size should be less than 2 MB))</aspan></strong>
<input type="file" class="form-control pb-4"value="{{ old('AdditionDoucument')??$cv->AdditionDoucument }}" name="AdditionDoucument" style=padding-top:4px; >
</div>
<input type="submit" value="Submit" class="btn btn-primary ">
Still the img is not updated , however the files and other fields are updated? I dont know what to do ? I spend one two days trying to figure out the reason but nothing works, can anybody help me please ?
Please or to participate in this conversation.