Skip to content

Commit 86461be

Browse files
author
FreedomKnight
committed
新增 method 並且處理其他 file not found exception
1 parent 5d1d883 commit 86461be

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/FileEntry.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ private function moveFile($upload_file, $cus_name)
4040
return $filename;
4141
}
4242

43+
public function fullpath($filename)
44+
{
45+
if (mb_substr($this->basepath, -1, 1, 'utf8') != '/') {
46+
$this->basepath .= '/';
47+
}
48+
49+
if (preg_match('/^\//', $filename)) {
50+
return $this->basepath . mb_substr($filename, 1, null, 'utf8');
51+
}
52+
53+
return $this->basepath . $filename;
54+
}
55+
4356
public function response($filename)
4457
{
4558
try {
@@ -62,6 +75,8 @@ public function response($filename)
6275
return response(null, 304)->setPublic();
6376
} catch (FileNotFoundException $e) {
6477
abort(404);
78+
} catch (\Illuminate\Contracts\Filesystem\FileNotFoundException $e) {
79+
abort(404);
6580
}
6681
}
6782
}

0 commit comments

Comments
 (0)