本文整理匯總了PHP中app\File::IsValidNameName方法的典型用法代碼示例。如果您正苦於以下問題:PHP File::IsValidNameName方法的具體用法?PHP File::IsValidNameName怎麽用?PHP File::IsValidNameName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\File
的用法示例。
在下文中一共展示了File::IsValidNameName方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: newReview
public function newReview(Request $request)
{
$this->validate($request, ['review_name' => 'required|max:255', 'file' => 'required']);
$id = uniqid();
$name = $request->input('review_name');
$file = $request->file('file');
$review = new Review();
$review->id = $id;
$review->name = $name;
$review->save();
if ($file->getMimeType() == 'application/zip') {
$zip = zip_open($request->file('file')->getPathName());
if (is_resource($zip)) {
while ($zip_entry = zip_read($zip)) {
$name = zip_entry_name($zip_entry);
$size = zip_entry_filesize($zip_entry);
if (zip_entry_open($zip, $zip_entry, 'r')) {
$contents = zip_entry_read($zip_entry, $size);
$finfo = new \finfo(FILEINFO_MIME_TYPE);
$type = $finfo->buffer($contents);
if (in_array($type, File::$AcceptTypes) && File::IsValidNameName($name)) {
$dbFile = new File();
$dbFile->review_id = $id;
$dbFile->contents = $contents;
$dbFile->type = $type;
$dbFile->name = $name;
$dbFile->size = $size;
$dbFile->save();
}
}
zip_entry_close($zip_entry);
}
}
} else {
$dbFile = new File();
$dbFile->review_id = $id;
$dbFile->contents = file_get_contents($request->file('file')->getPathname());
$dbFile->type = $file->getMimeType();
$dbFile->name = $file->getClientOriginalName();
$dbFile->size = $file->getClientSize();
$dbFile->save();
}
return redirect('reviews/' . $id);
}