本文整理汇总了PHP中app\File::uploadThumbAndMainImage方法的典型用法代码示例。如果您正苦于以下问题:PHP File::uploadThumbAndMainImage方法的具体用法?PHP File::uploadThumbAndMainImage怎么用?PHP File::uploadThumbAndMainImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\File
的用法示例。
在下文中一共展示了File::uploadThumbAndMainImage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadImage
public function uploadImage(Request $request)
{
$galleryId = $request->input('galleryId');
// check if the file exist
if (!$request->hasFile('file')) {
return response('No file sent.', 400);
}
// check if the file is valid file
if (!$request->file('file')->isValid()) {
return response('File is not valid.', 400);
}
// validation rules
$validator = Validator::make($request->all(), ['galleryId' => 'required|integer', 'file' => 'required|mimes:jpeg,jpg,png|max:8000']);
// if validation fails
if ($validator->fails()) {
return response('There are errors in the form data', 400);
}
$fileObj = new File();
$fileUpload = $fileObj->uploadThumbAndMainImage($request);
return response($fileUpload, 201);
}