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(); }
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);