2 namespace TYPO3\CMS\Core\Http;
79 if (is_string($input)) {
83 if (is_resource($input)) {
84 $this->stream =
new Stream($input);
86 $this->stream = $input;
89 if (!$this->file && !$this->stream) {
90 throw new \InvalidArgumentException(
'The input given was not a valid stream or file.', 1436717301);
94 throw new \InvalidArgumentException(
'The size provided for an uploaded file must be an integer.', 1436717302);
98 if (!is_int($errorStatus) || 0 > $errorStatus || 8 < $errorStatus) {
99 throw new \InvalidArgumentException(
'Invalid error status for an uploaded file. See UPLOAD_ERR_* constant in PHP.', 1436717303);
101 $this->error = $errorStatus;
104 throw new \InvalidArgumentException(
'Invalid client filename provided for an uploaded file.', 1436717304);
109 throw new \InvalidArgumentException(
'Invalid client media type provided for an uploaded file.', 1436717305);
129 throw new \RuntimeException(
'Cannot retrieve stream as it was moved.', 1436717306);
136 $this->stream =
new Stream($this->file);
173 if (!is_string($targetPath) || empty($targetPath)) {
174 throw new \InvalidArgumentException(
'Invalid path while moving an uploaded file.', 1436717307);
178 throw new \RuntimeException(
'Cannot move uploaded file, as it was already moved.', 1436717308);
183 if (empty($targetPath)) {
184 throw new \RuntimeException(
'Cannot move uploaded file, as it was already moved.', 1436717309);
187 if (!empty($this->file) && is_uploaded_file($this->file)) {
189 throw new \RuntimeException(
'An error occurred while moving uploaded file', 1436717310);
191 }
elseif ($this->stream) {
192 $handle = fopen($targetPath,
'wb+');
193 if ($handle ===
false) {
194 throw new \RuntimeException(
'Unable to write to target path.', 1436717311);
197 $this->stream->rewind();
198 while (!$this->stream->eof()) {
199 fwrite($handle, $this->stream->read(4096));