Skip to content

Commit 9432498

Browse files
committed
refactor: path may have no separator
1 parent 15482b3 commit 9432498

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

app/Coding/Wiki.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function createWiki($token, $projectName, $data)
2727

2828
public function createMarkdownZip($markdown, $path, $markdownFilename): bool|string
2929
{
30-
$zipFileFullPath = sys_get_temp_dir() . '/' . $markdownFilename . '-' . Str::uuid() . '.zip';
30+
$zipFileFullPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $markdownFilename . '-' . Str::uuid() . '.zip';
3131
if ($this->zipArchive->open($zipFileFullPath, ZipArchive::CREATE) !== true) {
3232
Log::error("cannot open <$zipFileFullPath>");
3333
return false;
@@ -39,11 +39,12 @@ public function createMarkdownZip($markdown, $path, $markdownFilename): bool|str
3939
// markdown image title: ![](images/default.svg "admin")
4040
$tmp = explode(' ', $attachment);
4141
$filename = $tmp[0];
42-
if (!file_exists($path . $filename)) {
42+
$filepath = $path . DIRECTORY_SEPARATOR . $filename;
43+
if (!file_exists($filepath)) {
4344
error_log("文件不存在:$filename");
4445
continue;
4546
}
46-
$this->zipArchive->addFile($path . $filename, $filename);
47+
$this->zipArchive->addFile($filepath, $filename);
4748
}
4849
}
4950
$this->zipArchive->close();

0 commit comments

Comments
 (0)