本文整理汇总了PHP中FileUpload::getValue方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUpload::getValue方法的具体用法?PHP FileUpload::getValue怎么用?PHP FileUpload::getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUpload
的用法示例。
在下文中一共展示了FileUpload::getValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateHasSuffix
/**
* HasSuffix validator: has file specified suffix?
* @param FileUpload
* @param string suffix(es) separated by comma [comma and space]
* @return bool
*/
public static function validateHasSuffix(FileUpload $control, $allowedSuffixes)
{
$file = $control->getValue();
if ($file instanceof HttpUploadedFile) {
$allowedSuffixes = preg_split('/,\\s*/', $allowedSuffixes);
foreach ($allowedSuffixes as $v) {
if (preg_match("/.*\\.{$v}\$/i", $file->name)) {
return TRUE;
}
}
}
return FALSE;
}
示例2: validateMimeType
/**
* MimeType validator: has file specified mime type?
* @param FileUpload
* @param array|string mime type
* @return bool
*/
public static function validateMimeType(FileUpload $control, $mimeType)
{
$file = $control->getValue();
if ($file instanceof HttpUploadedFile) {
$type = $file->getContentType();
$type = strtolower(preg_replace('#\\s*;.*$#', '', $type));
if (!$type) {
return FALSE;
// cannot verify :-(
}
$mimeTypes = is_array($mimeType) ? $mimeType : explode(',', $mimeType);
if (in_array($type, $mimeTypes, TRUE)) {
return TRUE;
}
if (in_array(preg_replace('#/.*#', '/*', $type), $mimeTypes, TRUE)) {
return TRUE;
}
}
return FALSE;
}
示例3: validateImage
/**
* Image validator: is file image?
* @param FileUpload
* @return bool
*/
public static function validateImage(FileUpload $control)
{
$file = $control->getValue();
return $file instanceof HttpUploadedFile && $file->isImage();
}