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