Skip to content

Commit 2befe6d

Browse files
authored
Merge pull request #20 from sarhugo/19-validation-on-filename-while-upload
19 validation on filename while upload
2 parents 6d79c25 + 738844e commit 2befe6d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Client.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,11 +564,16 @@ public function upload($path)
564564
$guzzle = new GuzzleClient([
565565
'base_uri' => $this->getApiRoot()
566566
]);
567+
$fileinfo = pathinfo($path);
568+
$filename = preg_replace('/\W+/', '_', $fileinfo['filename']);
569+
if (isset($fileinfo['extension'])) {
570+
$filename .= '.' . $fileinfo['extension'];
571+
}
567572
$options = [
568573
'multipart' => [
569574
[
570-
'name' => basename($path),
571-
'filename' => basename($path),
575+
'name' => 'source',
576+
'filename' => $filename,
572577
'contents' => fopen($path, 'r')
573578
]
574579
],

0 commit comments

Comments
 (0)