Level 4
Fixed. Laravel 5 got confused with my local variable and $request->file('same as local variable name'). Dunno why but solved it by using different name.
public function store(AdminProgramRequest $request)
{
$request = $this->move_image_file($request, 'thumbnail');
$request = $this->move_image_file($request, 'korean_brochure');
$request = $this->move_image_file($request, 'english_brochure');
$request = $this->move_image_file($request, 'chinese_brochure');
Program::create($request->all());
return redirect('dashboard/program_category/'.$request->program_category_id.'/edit');
}
private function move_image_file($request, $input_name)
{
if($request->hasFile($input_name)){
$filename = $request->file($input_name)->getClientOriginalName();
$request->file($input_name)->move(
base_path() . '/public/pdf/program_category/' . $request->program_category_id . '/' , $filename
);
$request->merge([
// I think this is where
// /private/var/folders/_l/9jdb6p2s3ms4vh8jv0mp_43w0000gn/T/phphi95xw
// stuff gets stored in $request even if
// $filename has the uploaded filename for sure.
$input_name => $filename
// This hardcode also works in the same way and stores weird path in db... WHY!?
// $input_name => 'whats_going_on.jpg'
]);
}
return $request;
}
This is driving me nuts. I'm pretty sure that $filename has the filename of the uploaded file.
Now, I'm suspecting MAMP.
Has anyone experienced the same issue with Laravel5 and Mamp on OSX?
Fixed. Laravel 5 got confused with my local variable and $request->file('same as local variable name'). Dunno why but solved it by using different name.
Please or to participate in this conversation.