/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
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;
}
这让我疯了。我很确定$ filename有上传文件的文件名。
现在,我怀疑是MAMP。
有没有人在OSX上遇到与Laravel5和Mamp相同的问题?