在Laravel 5.2中上传异常

时间:2018-06-13 09:13:11

标签: laravel

我想在laravel 5.2中创建一个自定义上传器

我的意思是我想忽略用户在我的文件上传器中上传'php files'

我该怎么办?

这是我的控制器和方法代码:

public function workfreport(Request $request)
{

    $reportFile = $request->file('reportFile');

    if($reportFile == '')
    {

    }
    else {
        $reportFileName = date('Y-m-d-H-i-s') . "-" . rand() . "-" . $reportFile->getClientOriginalName();
        $reportFile->move('uploads/files/reports', $reportFileName);
    }

    $workreport = new WorkReport;
    $workreport->details = Input::get('detailsreport');
    if($reportFile == '')
    {

    }
    else {
        $workreport->reportfile_url = $reportFileName;
    }
    $workreport->reporter_id = Input::get('reporterid');
    $workreport->date = Input::get('reportDate');
    $workreport->save();

    return redirect()->back();
}

0 个答案:

没有答案