diff --git a/readme.md b/readme.md index ce08d66..6573be3 100644 --- a/readme.md +++ b/readme.md @@ -10,7 +10,7 @@ To install, use composer: ## How to use **upload.php** -``` +```php getOriginalFilename(Resumable::WITHOUT_EXTENSION); // will gove you "original Name" instead of "original Name.png" @@ -62,6 +62,6 @@ if (true === $resumable->isUploadComplete()) { // true when the final file has b ``` ## Testing -``` +```sh $ ./vendor/bin/phpunit ``` diff --git a/src/Resumable.php b/src/Resumable.php index a487237..294a447 100644 --- a/src/Resumable.php +++ b/src/Resumable.php @@ -70,7 +70,7 @@ public function setResumableOption(array $resumableOption) $this->resumableOption = array_merge($this->resumableOption, $resumableOption); } - // sets original filename and extenstion, blah blah + // sets original filename and extension, blah blah public function preProcess() { if (!empty($this->resumableParams())) { @@ -177,9 +177,9 @@ public function handleTestChunk() { $identifier = $this->resumableParam($this->resumableOption['identifier']); $filename = $this->resumableParam($this->resumableOption['filename']); - $chunkNumber = $this->resumableParam($this->resumableOption['chunkNumber']); - $chunkSize = $this->resumableParam($this->resumableOption['chunkSize']); - $totalChunks = $this->resumableParam($this->resumableOption['totalChunks']); + $chunkNumber = (int) $this->resumableParam($this->resumableOption['chunkNumber']); + $chunkSize = (int) $this->resumableParam($this->resumableOption['chunkSize']); + $totalChunks = (int) $this->resumableParam($this->resumableOption['totalChunks']); if (!$this->isChunkUploaded($identifier, $filename, $chunkNumber)) { return $this->response->header(204); @@ -199,9 +199,9 @@ public function handleChunk() $file = $this->request->file(); $identifier = $this->resumableParam($this->resumableOption['identifier']); $filename = $this->resumableParam($this->resumableOption['filename']); - $chunkNumber = $this->resumableParam($this->resumableOption['chunkNumber']); - $chunkSize = $this->resumableParam($this->resumableOption['chunkSize']); - $totalChunks = $this->resumableParam($this->resumableOption['totalChunks']); + $chunkNumber = (int) $this->resumableParam($this->resumableOption['chunkNumber']); + $chunkSize = (int) $this->resumableParam($this->resumableOption['chunkSize']); + $totalChunks = (int) $this->resumableParam($this->resumableOption['totalChunks']); if (!$this->isChunkUploaded($identifier, $filename, $chunkNumber)) { $chunkFile = $this->tmpChunkDir($identifier) . DIRECTORY_SEPARATOR . $this->tmpChunkFilename($filename, $chunkNumber); @@ -243,7 +243,7 @@ private function createFileAndDeleteTmp($identifier, $filename) if ($this->createFileFromChunks($chunkFiles, $this->filepath) && $this->deleteTmpFolder) { $tmpFolder->delete(); - $this->uploadComplete = true; + $this->isUploadComplete = true; } } @@ -295,14 +295,14 @@ public function tmpChunkDir($identifier) /** * make directory if it doesn't exists (Immune against the race condition) - * - * - * since the resuamble is usually used with simultaneously uploads, - * this sometimes resulted in directory creation btween the *is_dir* check + * + * + * since the resumable is usually used with simultaneously uploads, + * this sometimes resulted in directory creation between the *is_dir* check * and *mkdir* then following race condition. * in this setup it will shut down the mkdir error * then try to check if directory is created after that - * + * * @param string $path the directoryPath to ensure * @return void * @throws \Exception @@ -361,7 +361,7 @@ public function createFileFromChunks($chunkFiles, $destFile) public function moveUploadedFile($file, $destFile) { - //workaround cakephp error regarding: TMP not defined + //workaround cakephp error regarding: TMP not defined define("TMP",sys_get_temp_dir()); $file = new File($file);