本文整理匯總了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);
}