lib/Remote/RemoteWebElement.php
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;
    }
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;
    }
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 ; }
Upload a local file to the server

@param string $local_file

@throws WebDriverException
@return string The remote path of the file.
Upload a local file to the server