Обычный файл копируется, загруженный - move_uploaded_file

@return \Symfony\Component\HttpFoundation\File\File
331133
public function copy($destination)
  {
    $f = $this->getValue();

    if ($f) {
      $arr = pathinfo($destination);
      if ($f instanceof UploadedFile) {
        return $f->move($arr['dirname'], $arr['basename']);
      } else {
        if (!@copy($f->getRealPath(), $destination)) {
          $error = error_get_last();

          throw new FileException(
            sprintf(
              'Could not move the file "%s" to "%s" (%s)',
              $f->getPathname(),
              $destination,
              strip_tags($error['message'])
            )
          );
        }

        return new \Symfony\Component\HttpFoundation\File\File($destination);
      }
    }

    return false;
  }
308721
public function uploadedFiles()
    {
        if (!$this->files) {
            $this->files = new UploadedFiles($_FILES);
        }
        return $this->files->files();
    }
61023
public function getFileContent()
    {
        $file = $this->getAttribute('file');
        if (empty($file) && !$this->getIsNewRecord()) {
            $file = $this->refreshFile();
        }

        if (empty($file)) {
            return null;
        } elseif ($file instanceof Download) {
            $fileSize = $file->getSize();
            return empty($fileSize) ? null : $file->toString();
        } elseif ($file instanceof UploadedFile) {
            return file_get_contents($file->tempName);
        } elseif (is_string($file)) {
            if (file_exists($file)) {
                return file_get_contents($file);
            }
            throw new InvalidParamException("File '{$file}' does not exist.");
        }

        throw new InvalidParamException('Unsupported type of "file" attribute.');
    }
688714
protected function moveFile(UploadedFile $file)
    {
        $path = $this->getUploadPath();
        $name = $this->generateFilename($path, $file->guessExtension());

        while (file_exists($path.$name)) {
            $name = $this->generateFilename($extension);
        }

        $file->move($path, $name);
        return $name;
    }
1133674
protected function moveUploadedFiles()
    {
        $i = 0;
        if (is_array($this->move_uploaded_queue)) {
            foreach ($this->move_uploaded_queue as $key => $queue_item) {
                if (is_array($queue_item) && isset($queue_item['name']) && isset($queue_item['tmp_name']) && isset($queue_item['new_name'])) {
                    $destination_name = $queue_item['new_name'];

                    if ($this->overwrite === false) {
                        // verify file exists and set new name.
                        $destination_name = $this->renameDuplicateFile($destination_name);
                    }

                    $move_result = move_uploaded_file($queue_item['tmp_name'], $this->move_uploaded_to.DIRECTORY_SEPARATOR.$destination_name);
                    if ($move_result === true) {
                        // move uploaded file success. add status and some data to array.
                        $this->move_uploaded_queue[$key] = array_merge(
                            $this->move_uploaded_queue[$key], 
                            array(
                                'new_name' => $destination_name,
                                'move_uploaded_status' => 'success',
                                'move_uploaded_to' => $this->move_uploaded_to.DIRECTORY_SEPARATOR.$destination_name,
                            )
                        );
                        $i++;
                    } else {
                        $this->setErrorMessage(
                            sprintf(static::__('Unable to move uploaded file. (%s =&gt; %s)'), $queue_item['name'], $this->move_uploaded_to . DIRECTORY_SEPARATOR . $destination_name),
                            'RDU_MOVE_UPLOADED_FAILED',
                            $queue_item['name'] . '=&gt; ' . $this->move_uploaded_to . DIRECTORY_SEPARATOR . $destination_name
                        );
                    }

                    unset($destination_name, $move_result);
                }
            }// endforeach;
            unset($key, $queue_item);
        }

        if ($i == count($this->move_uploaded_queue) && $i > 0) {
            return true;
        } else {
            return false;
        }
    }
556329
public function uploadChunk ()
		{
			move_uploaded_file($this->_file[ 'tmp_name' ], $this->chunkPath);

			Yii::$app->response->setStatusCode(200);
		}
287764
public function move(){
    
        try {
            $this->file->move(Input::get('draggedId'), Input::get('droppedId'));

            return response()->json([
                'status' => 'success'
            ]);
        } 

        catch (Exception $e) {
            return $this->handleError($e);
        }
    }
554034
public function upload()
    {
        $filename = $this->getName(true);

        if ( ! is_readable($filename) ) {
            throw new FileExistException('Image file from disk is not readable');
        }

        try {
            $this->getSoapClient()->UploadImage(array(
                'image'    => base64_encode(file_get_contents($filename)) ,
                'filename' => basename($filename) ,
            ));

            return $this;
        } catch ( SoapException $e ) {
            throw new UploadException('Error while uploading the image' , $e);
        }
    }
1009552
public function upload()
    {
        $files = request()->file('file');
        $error_bag = [];
        foreach (is_array($files) ? $files : [$files] as $file) {
            $validation_message = $this->uploadValidator($file);
            $new_filename = $this->proceedSingleUpload($file);

            if ($validation_message !== 'pass') {
                array_push($error_bag, $validation_message);
            } elseif ($new_filename == 'invalid') {
                array_push($error_bag, $response);
            }
        }

        if (is_array($files)) {
            $response = count($error_bag) > 0 ? $error_bag : parent::$success_response;
        } else { // upload via ckeditor 'Upload' tab
            $response = $this->useFile($new_filename);
        }

        return $response;
    }
1039714
public function upload()
    {
        try {
            $templatecontent = $this->getBase64Contents();
            $filename        = basename($this->getName());
        } catch ( FileExistException $ex ) {
            throw new FileExistException('Template file does not exist or is not readable' , $ex);
        }

        try {
            $this->getSoapClient()->UploadTemplate([
                'template' => $templatecontent ,
                'filename' => $filename ,
            ]);

            $remoteTemplate = new Remote($this->getSoapClient());
            $remoteTemplate->setName($this->getName());

            return $remoteTemplate;
        } catch ( SoapException $ex ) {
            throw new UploadException('Error while uploading the template' , $ex);
        }
    }
1155198
public function setTargetfile()
	{
		//set the upload_path_relative
		$this->upload_path_relative = $this->upload_path . $this->target_file_name;

		//set the full target file path
		$this->target_file = $this->target_dir . $this->target_file_name;

		return $this;

	}
531871
public function uploadAction ()
    {
        $handle = $this->getRequest()->files->get('file');
        
        if ($handle && $handle->getError()){
            return new JsonResponse(array(
                'success' => false,
                'err_msg' => $this->container->get('translator')
                    ->trans('file_upload_http_error', array(), 'ThraceMediaBundle')
            ));
        }

        $imageManager = $this->container->get('thrace_media.imagemanager');
        $options = $this->container->getParameter('thrace_media.plupload.options');
        $extension = $handle->getClientOriginalExtension();
        $name = uniqid() . '.' . $extension;
        
        if(!$extension){
            return new JsonResponse(array(
                'success' => false,
                'err_msg' => sprintf('Unknown Mime Type: "%s"', $handle->getMimeType())
            ));
        }

        $validate = $this->validateImage($handle);

        if ($validate !== true) {
            return new JsonResponse(array(
                'success' => false,
                'err_msg' => $validate
            ));
        }

        $content = $imageManager->normalizeImage(
            $name, file_get_contents($handle->getRealPath()), 
            $options['normalize_width'], $options['normalize_height']
        );
        
        $imageManager->saveToTemporaryDirectory($name, $content);
        $imageManager->makeImageCopyToOriginalDirectory($name);
        $hash = $imageManager->checksumTemporaryFileByName($name);

        return new JsonResponse(array(
            'success' => true,
            'name'    => $name,
            'hash'    => $hash
        ));
    }
516716
public function handleUpload() {
		$files = $this->request->getFiles();
		$token = $this->request->getPost("token");
		$params = json_decode($this->request->getPost("params"), true);
		
		/** @var \Nette\Http\FileUpload $file */
		$file = $files[ $this->uploadControl->getHtmlName() ];
		/** @noinspection PhpInternalEntityUsedInspection */
		$model = $this->uploadControl->getUploadModel();
		$cache = $this->uploadControl->getCache();
		$filter = $this->getFilter();
		
		try {
			if(!is_null($filter) && !$filter->checkType($file)) {
				throw new \Zet\FileUpload\InvalidFileException($this->getFilter()->getAllowedTypes());
			}
			
			if($file->isOk()) {
				$returnData = $model->save($file, $params);
				/** @noinspection PhpInternalEntityUsedInspection */
				$cacheFiles = $cache->load($this->uploadControl->getTokenizedCacheName($token));
				if(empty($cacheFiles)) {
					$cacheFiles = [$this->request->getPost("id") => $returnData];
				} else {
					$cacheFiles[ $this->request->getPost("id") ] = $returnData;
				}
				/** @noinspection PhpInternalEntityUsedInspection */
				$cache->save($this->uploadControl->getTokenizedCacheName($token), $cacheFiles);
			}
			
		} catch(\Zet\FileUpload\InvalidFileException $e) {
			$this->presenter->sendResponse(new \Nette\Application\Responses\JsonResponse([
				"id" => $this->request->getPost("id"),
				"error" => 100,
				"errorMessage" => $e->getMessage()
			]));
			
		} catch(\Exception $e) {
			$this->presenter->sendResponse(new \Nette\Application\Responses\JsonResponse([
				"id" => $this->request->getPost("id"),
				"error" => 99,
				"errorMessage" => $e->getMessage()
			]));
		}
		
		$this->presenter->sendResponse(new \Nette\Application\Responses\JsonResponse([
			"id" => $this->request->getPost("id"),
			"error" => $file->getError()
		]));
	}
430238
public function upload(UploadedFile $file = null)
    {
        if ($file === null) {
            return '';
        }

        $fileName = $this->getFileName($file);
        $file->move($this->getTargetDir(), $fileName);

        return $fileName;
    }
1065109
private function getTransport()
    {
        if ($this->transport) {
            return $this->transport;
        }

        $transportClassName = '\\Sokil\\Upload\\Transport\\' . $this->options['transport'] . 'Transport';

        $this->transport = new $transportClassName(
            $this->options['fieldName'],
            $this->options['supportedFormats'],
            $this->options['validateChecksum']
        );
        
        return $this->transport;
    }
201202
public function updateUpload()
    {
        if (null === $this->getFile()) {
            return null;
        }

        $this->moveFile();

        // check if we have an old image
        if (isset($this->temp)) {
            // delete the old image
            @unlink($this->getUploadRootDir() . $this->temp);

            // clear the temp image path
            $this->temp = null;
        }

        return $this->getUploadRootDir() . $this->path;
    }
640207
protected function uploadFile () : bool
	{
		// Determine the destination
		$this->newFileLocation = $this->getUploadDir().$this->uploadFileDir.getConstant('DS', TRUE).$this->newFileName;			  
		// Make sure a file doesn't already exist in the target location
		if (file_exists($this->newFileLocation)):
			$this->error = "The file {$this->newFileLocation} already exists.";
			return FALSE;
		endif;
		// Attempt to move/upload the file 
		if (!move_uploaded_file($this->tempPath, $this->newFileLocation)):
			// File was not moved - failure.
			$this->error = "The file upload failed.";
			return FALSE;
		endif;
		// SUCCESS
		return TRUE;
	}