From b453773ff26b820b07e30d3250db65c2375b7a42 Mon Sep 17 00:00:00 2001 From: sparchatus <8504034+sparchatus@users.noreply.github.com> Date: Mon, 20 Apr 2020 11:16:41 +0200 Subject: [PATCH] Fix #308: Fix `yii\mongodb\file\Upload::addFile()` error when uploading file with readonly permissions --- CHANGELOG.md | 2 +- src/file/Upload.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2d14a042..c7672b201 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Yii Framework 2 mongodb extension Change Log 2.1.10 under development ------------------------ -- no changes in this release. +- Bug #308: Fix `yii\mongodb\file\Upload::addFile()` error when uploading file with readonly permissions (sparchatus) 2.1.9 November 19, 2019 diff --git a/src/file/Upload.php b/src/file/Upload.php index 6bd1b0f5a..fb9dd9ad4 100644 --- a/src/file/Upload.php +++ b/src/file/Upload.php @@ -178,7 +178,7 @@ public function addFile($filename) $this->filename = basename($filename); } - $stream = fopen($filename, 'r+'); + $stream = fopen($filename, 'r'); if ($stream === false) { throw new InvalidParamException("Unable to read file '{$filename}'"); } @@ -277,4 +277,4 @@ private function insertFile() $this->collection->insert($fileDocument); return $fileDocument; } -} \ No newline at end of file +}