本文整理汇总了PHP中file::type方法的典型用法代码示例。如果您正苦于以下问题:PHP file::type方法的具体用法?PHP file::type怎么用?PHP file::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file
的用法示例。
在下文中一共展示了file::type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upload
public function upload()
{
//上传文件
$this->files = $this->upload->save();
//设置错误
if ($this->upload->error()) {
$this->error($this->upload->error(), $this->upload->msg());
}
if (is_array($this->files)) {
//保存文件
$ip = ip::current();
$userid = $this->_user['id'];
$description = (array) $this->description;
foreach ($this->files as $key => $file) {
$file['id'] = $file['id'];
$file['parentid'] = $file['id'];
$file['globalid'] = $this->globalid;
$file['groupid'] = $this->folderid;
$file['field'] = $this->field;
$file['type'] = file::type($file['path']);
$file['description'] = empty($description[$key]) ? $file['description'] : $description[$key];
$file['userid'] = $userid;
$file['status'] = (int) $this->status;
$file['createip'] = $ip;
$file['createtime'] = TIME;
if ($file['type'] == 'image' || preg_match('/^(jpeg|jpeg|png|gif|bmp|ico|tif|tiff|psd|xbm|xcf)$/', $file['ext'])) {
$info = image::info($file['path']);
$file['width'] = (int) $info['width'];
$file['height'] = (int) $info['height'];
}
$this->insert($file);
}
return $this->files;
}
return array();
}
示例2: die
die("There sould be more than 1 file.");
}
foreach ($files as &$file) {
$file = new file($file);
}
file::$type = "fileSize";
echo 'Zero sort' . "\n";
sort($files, SORT_STRING);
echo 'Zero deleteUnique' . "\n";
$files = deleteUnique($files);
file::$type = "shortHash";
echo 'First sort' . "\n";
sort($files, SORT_STRING);
echo 'First deleteUnique' . "\n";
$files = deleteUnique($files);
file::$type = "fullHash";
echo 'Second sort' . "\n";
sort($files, SORT_STRING);
echo 'Second deleteUnique' . "\n";
$files = deleteUnique($files);
echo 'Outputing' . "\n";
chdir($curDir);
// getFilesFromDir can change cDir. So rewind.
file_put_contents($output, "============================ Result ============================\r\n");
$lastIndex = count($files) - 1;
$filesBlock = array();
for ($i = 0; $i <= $lastIndex; $i++) {
$filesBlock[] = $files[$i]->path;
if ($i === $lastIndex || (string) $files[$i] != $files[$i + 1]) {
$op = 'S';
sort($filesBlock, SORT_STRING);