lib/Dropbox/Client.php
function uploadFile($path, $writeMode, $inStream, $numBytes = null)
    {
        Path::checkArgNonRoot("path", $path);
        WriteMode::checkArg("writeMode", $writeMode);
        Checker::argResource("inStream", $inStream);
        Checker::argNatOrNull("numBytes", $numBytes);

        // If we don't know how many bytes are coming, we have to use chunked upload.
        // If $numBytes is large, we elect to use chunked upload.
        // In all other cases, use regular upload.
        if ($numBytes === null || $numBytes > self::$AUTO_CHUNKED_UPLOAD_THRESHOLD) {
            $metadata = $this->_uploadFileChunked($path, $writeMode, $inStream, $numBytes,
                                                  self::$DEFAULT_CHUNK_SIZE);
        } else {
            $metadata = $this->_uploadFile($path, $writeMode,
                function(Curl $curl) use ($inStream, $numBytes) {
                    $curl->set(CURLOPT_PUT, true);
                    $curl->set(CURLOPT_INFILE, $inStream);
                    $curl->set(CURLOPT_INFILESIZE, $numBytes);
                });
        }

        return $metadata;
    }
function uploadFile($path, $writeMode, $inStream, $numBytes = null)
    {
        Path::checkArgNonRoot("path", $path);
        WriteMode::checkArg("writeMode", $writeMode);
        Checker::argResource("inStream", $inStream);
        Checker::argNatOrNull("numBytes", $numBytes);

        // If we don't know how many bytes are coming, we have to use chunked upload.
        // If $numBytes is large, we elect to use chunked upload.
        // In all other cases, use regular upload.
        if ($numBytes === null || $numBytes > self::$AUTO_CHUNKED_UPLOAD_THRESHOLD) {
            $metadata = $this->_uploadFileChunked($path, $writeMode, $inStream, $numBytes,
                                                  self::$DEFAULT_CHUNK_SIZE);
        } else {
            $metadata = $this->_uploadFile($path, $writeMode,
                function(Curl $curl) use ($inStream, $numBytes) {
                    $curl->set(CURLOPT_PUT, true);
                    $curl->set(CURLOPT_INFILE, $inStream);
                    $curl->set(CURLOPT_INFILESIZE, $numBytes);
                });
        }

        return $metadata;
    }
function uploadFile ( $ path , $ writeMode , $ inStream , $ numBytes = null ) { Path :: checkArgNonRoot ( "path" , $ path ) ; WriteMode :: checkArg ( "writeMode" , $ writeMode ) ; Checker :: argResource ( "inStream" , $ inStream ) ; Checker :: argNatOrNull ( "numBytes" , $ numBytes ) ; // If we don't know how many bytes are coming, we have to use chunked upload. // If $numBytes is large, we elect to use chunked upload. // In all other cases, use regular upload. if ( $ numBytes === null || $ numBytes > self :: $ AUTO_CHUNKED_UPLOAD_THRESHOLD ) { $ metadata = $ this -> _uploadFileChunked ( $ path , $ writeMode , $ inStream , $ numBytes , self :: $ DEFAULT_CHUNK_SIZE ) ; } else { $ metadata = $ this -> _uploadFile ( $ path , $ writeMode , function ( Curl $ curl ) use ( $ inStream , $ numBytes ) { $ curl -> set ( CURLOPT_PUT , true ) ; $ curl -> set ( CURLOPT_INFILE , $ inStream ) ; $ curl -> set ( CURLOPT_INFILESIZE , $ numBytes ) ; } ) ; } return $ metadata ; }
Creates a file on Dropbox, using the data from `$inStream` for the file contents.

<code>
use \Dropbox as dbx;
$client = ...;
$fd = fopen("./frog.jpeg", "rb");
$md1 = $client->uploadFile("/Photos/Frog.jpeg",
dbx\WriteMode::add(), $fd);
fclose($fd);
print_r($md1);
$rev = $md1["rev"];

// Re-upload with WriteMode::update(...), which will overwrite the
// file if it hasn't been modified from our original upload.
$fd = fopen("./frog-new.jpeg", "rb");
$md2 = $client->uploadFile("/Photos/Frog.jpeg",
dbx\WriteMode::update($rev), $fd);
fclose($fd);
print_r($md2);
</code>

@param string $path
The Dropbox path to save the file to (UTF-8).

@param WriteMode $writeMode
What to do if there's already a file at the given path.

@param resource $inStream
The data to use for the file contents.

@param int|null $numBytes
You can pass in `null` if you don't know.  If you do provide the size, we can
perform a slightly more efficient upload (fewer network round-trips) for files smaller
than 8 MB.

@return mixed
The <a href="https://www.dropbox.com/developers/core/docs#metadata-details>metadata
object</a> for the newly-added file.

@throws Exception
Creates a file on Dropbox using the data from $inStream for the file contents .