Upload a local file to remote.

@param string      $file
@param string|null $destination
764625
public function upload($file, $destination = null)
    {
        if (!file_exists($file)) {
            return;
        }

        // Get contents and destination
        $destination = $destination ?: basename($file);

        $this->put($destination, file_get_contents($file));
    }
750583
public function moveTo($destination) {
		if (!$this->isValid()) {
			return null;
		}

		$path = $this->generateFinalPath($destination);
		$moved = move_uploaded_file($this->tmpName, $path);

		if (!$moved) {
			return null;
		}

		return $path;
	}
1261634
public void upload(Path src, URI dst) throws IOException {
    if (remoteExists(dst)) {
      String msg = String.format("Destination URI %s already exists", dst);
      throw new IllegalArgumentException(msg);
    }
    copyToRemote(src, dst);
  }
718024
def put(localfile, remotefile = File.basename(localfile),
            blocksize = DEFAULT_BLOCKSIZE, &block)
      if @binary
        putbinaryfile(localfile, remotefile, blocksize, &block)
      else
        puttextfile(localfile, remotefile, &block)
      end
    end
254160
def upload_file(self, remote, local):
        
        file = open(local, 'rb')
        try:
            self.upload(remote, file)
        finally:
            file.close()
383420
protected function runScp($file, $destination_path, $server = null, $verbose = false)
    {
        $recursive_option = '';
        if (is_dir($file)) {
            $recursive_option = ' -r';
        }
        $server = $server ? $server : $this->hostNameForConfigFile();
        $ssh_config_file = $_SERVER['HOME'] . '/.ssh/config';
        $full_command = "scp -F ${ssh_config_file}$recursive_option $file $server:$destination_path";

        if ($verbose) {
            $this->info($full_command);
        }
        passthru($full_command);
    }
31550
protected function upload($local_file)
    {
        if (!is_file($local_file)) {
            throw new WebDriverException('You may only upload files: ' . $local_file);
        }

        // Create a temporary file in the system temp directory.
        $temp_zip = tempnam(sys_get_temp_dir(), 'WebDriverZip');
        $zip = new ZipArchive();
        if ($zip->open($temp_zip, ZipArchive::CREATE) !== true) {
            return false;
        }
        $info = pathinfo($local_file);
        $file_name = $info['basename'];
        $zip->addFile($local_file, $file_name);
        $zip->close();
        $params = [
            'file' => base64_encode(file_get_contents($temp_zip)),
        ];
        $remote_path = $this->executor->execute(
            DriverCommand::UPLOAD_FILE,
            $params
        );
        unlink($temp_zip);

        return $remote_path;
    }
820174
public function attachFile($file, $fileName = null)
    {
        if (gettype($file) == 'resource') {
            $this->file = ['fileName' => $fileName, 'fileContent' => $file];
        } else {
            $this->file = ['fileName' => $fileName, 'fileContent' => fopen($file, 'r')];
        }
    }
354489
protected function queueUploadedFile($file)
    {
        // Get the real path of the file
        $file = $this->getFileManager()
            ->make($file)
            ->getRealPath();

        // Create the unique directory name and file to save into
        $file_target = $this->joinPaths(
            str_replace('.', '-', uniqid(rand(), true)),
            basename($file)
        );

        // Parse the queue path
        $queue_path = $this->getInterpolator()->interpolate(
            $this->config('queue_path')
        );

        // Determine if the path is locale and just simple move it,
        // otherwise use the disk driver to move the attachment.
        if ($local_path = realpath($queue_path)) {
            $target = $this->joinPaths($local_path, $file_target);

            // Ensure the target directory exists
            if (is_dir(dirname($target)) === false) {
                mkdir(dirname($target), 0777, true);
            }

            // Move the file
            rename($file, $target);
        }
        else {
            $this->move(
                $file, $this->joinPaths($queue_path, $file_target)
            );
        }

        // Save the information for later
        $this->instanceWrite('queue_state', self::QUEUE_WAITING);
        $this->instanceWrite('queued_file', $file_target);
    }
623027
public function put($local_file = null, $remote_file = null, $mode = FTP_ASCII)
    {
        if (\ftp_put($this->_stream, $remote_file, $local_file, $mode)) {
            return true;
        }

        $this->error = 'Failed to upload file "'.$local_file.'"';

        return false;
    }
123171
public function upload( $file , $destination , $type = null){

        $name = $file->getClientOriginalName();
        $ext  = $file->getClientOriginalExtension();

        // Get the name first because after moving, the file doesn't exist anymore
        $new  = $file->move($destination,$name);
        $size = $new->getSize();
        $mime = $new->getMimeType();
        $path = $new->getRealPath();

        $image_name = basename($name,'.'.$ext);

        //resize
        if($type)
        {
            // resize if we have to
            $sizes = config('size.'.$type);
            $this->resize( $path, $image_name, $sizes['width'], $sizes['height']);
        }

        return array('name' => $name ,'ext' => $ext ,'size' => $size ,'mime' => $mime ,'path' => $path  );

	}
968487
public function upload(Filesystem $remote, $local, array $options = array())
    {
        if (!($remote instanceof File)) {
            throw new \InvalidArgumentException(sprintf(
                "Invalid remote file given, expected instance of File, got %s",
                get_class($remote)
            ));
        }

        if (true !== is_resource($local)) {
            throw new \InvalidArgumentException(sprintf(
                "Invalid local file given. Expected resource, got %s",
                gettype($local)
            ));
        }

        if (!isset($options[ FTP::NON_BLOCKING ]) || true !== $options[ FTP::NON_BLOCKING ]) {
            throw new \InvalidArgumentException("Invalid option given. Expected true as FTP::NON_BLOCKING parameter");
        }

        $defaults = array(
            FTP::NON_BLOCKING_CALLBACK => function() { },
            FTP::TRANSFER_MODE => FTPWrapper::BINARY,
            FTP::START_POS     => 0
        );
        $options  = $options + $defaults;
        $callback = $options[ FTP::NON_BLOCKING_CALLBACK ];

        $state = $this->wrapper->fputNb($remote->getRealpath(), $local, $options[ FTP::TRANSFER_MODE ], $options[ FTP::START_POS ]);
        call_user_func_array($callback, array());

        while ($state == FTPWrapper::MOREDATA) {
            $state = $this->wrapper->nbContinue();

            call_user_func_array($callback, array());
        }

        return $state === FTPWrapper::FINISHED;
    }
18735
protected function makeDestination(string $destination): void
    {
        if (! $this->files->isDirectory($destination)) {
            $this->files->makeDirectory($destination, 0777, true);
        }
    }
1141784
public function save($destination)
    {
        $fh = fopen($destination, 'wb');
        if (!$fh) {
            throw new FileOpenException('failed to open destination file: '.$destination);
        }

        if (!flock($fh, LOCK_EX | LOCK_NB, $blocked)) {
            // @codeCoverageIgnoreStart
            if ($blocked) {
                // Concurrent request has requested a lock.
                // File is being processed at the moment.
                // Warning: lock is not checked in windows.
                return false;
            }
            // @codeCoverageIgnoreEnd

            throw new FileLockException('failed to lock file: '.$destination);
        }

        $totalChunks = $this->request->getTotalChunks();

        try {
            $preProcessChunk = $this->config->getPreprocessCallback();

            for ($i = 1; $i <= $totalChunks; $i++) {
                $file = $this->getChunkPath($i);
                $chunk = fopen($file, "rb");

                if (!$chunk) {
                    throw new FileOpenException('failed to open chunk: '.$file);
                }

                if ($preProcessChunk !== null) {
                    call_user_func($preProcessChunk, $chunk);
                }

                stream_copy_to_stream($chunk, $fh);
                fclose($chunk);
            }
        } catch (\Exception $e) {
            flock($fh, LOCK_UN);
            fclose($fh);
            throw $e;
        }

        if ($this->config->getDeleteChunksOnSave()) {
            $this->deleteChunks();
        }

        flock($fh, LOCK_UN);
        fclose($fh);

        return true;
    }
161875
public function backup($destination)
    {
        $args = [
            (string)$destination
        ];
        return null === $this->rpc->query("backupWallet", $args);
    }
164691
public function move($destination) {
		$destination = $this->getDestination($destination);

		if (@rename($this->getPathname(), $destination)) {
			$this->pathname = $destination;
		} else {
			throw new FileException(sprintf('Failed to move %s to %s', $this->pathname, $destination));
		}
	}
857828
public function upload($destinationPath, $publicPath)
    {
        // Move takes the target directory and target filename as params
        $this->getFile()->move($destinationPath, $this->getFile()->getClientOriginalName());

        // Set the path property to the filename where you've saved the file
        $this->path = rtrim(str_ireplace($publicPath, '', $destinationPath), '/').'/'.$this->getFile()->getClientOriginalName();

        // Clean up the file property as you won't need it anymore
        $this->setFile(null);
    }