Esempio n. 1
0
require dirname(dirname(dirname(__DIR__))) . '/autoload.php';
use yxdj\network\Api;
use yxdj\network\Cli;
$args = Cli::parseArgs($argv, $argc);
/*
if (empty($args['s'])) {
    exit('please input `-s`.');
}

$uploadfile = $args['s'];
*/
if ($argc < 2 || empty($argv[1])) {
    exit('Error: please input download file');
}
$downloadfile = $downloadfile_o = $argv[1];
/*
$uploadfile = Cli::ask('please input path for upload file:');
//print_r($args);exit;

$uploadfile = './' .$uploadfile; 
*/
$data = Api::getStream()->request(['method' => 'POST', 'url' => 'http://192.168.1.59:37/test_server.php', 'row' => ['Xuyuan' => 'test'], 'get' => ['get1' => 'param2', 'get2' => ['a' => 'param2a', 'b' => 'param2b']], 'post' => ['type' => 'download', 'download' => $downloadfile], 'cookie' => ['cookie1' => 'param2', 'cookie2' => ['a' => 'param2a', 'b' => 'param2b']]])->getContent();
if ($data == '######') {
    echo 'not fond this file!';
    exit;
}
if (file_put_contents(basename($downloadfile), $data)) {
    echo 'ok';
} else {
    echo 'ng';
}
Esempio n. 2
0
<?php

/**
 * @link https://github.com/yxdj
 * @copyright Copyright (c) 2014 xuyuan All rights reserved.
 * @author xuyuan <*****@*****.**>
 */
//composer autoload
require dirname(dirname(dirname(__DIR__))) . '/autoload.php';
use yxdj\network\Api;
use yxdj\network\Cli;
$args = Cli::parseArgs($argv, $argc);
echo Api::getStream()->request(['method' => 'POST', 'url' => 'http://192.168.1.59:37/test_s.php', 'row' => ['Xuyuan' => 'test'], 'get' => ['get1' => 'param2', 'get2' => ['a' => 'param2a', 'b' => 'param2b']], 'post' => ['post1' => 'param2', 'post2' => ['a' => 'param2a', 'b' => 'param2b']], 'cookie' => ['cookie1' => 'param2', 'cookie2' => ['a' => 'param2a', 'b' => 'param2b']]])->getContent();
Esempio n. 3
0
//composer autoload
require dirname(dirname(dirname(__DIR__))) . '/autoload.php';
use yxdj\network\Api;
use yxdj\network\Cli;
$args = Cli::parseArgs($argv, $argc);
/*
if (empty($args['s'])) {
    exit('please input `-s`.');
}

$uploadfile = $args['s'];
*/
if ($argc < 2 || empty($argv[1])) {
    exit('Error: please input upload file');
}
$uploadfile = $uploadfile_o = $argv[1];
/*
$uploadfile = Cli::ask('please input path for upload file:');
//print_r($args);exit;

$uploadfile = './' .$uploadfile; 
*/
if (!is_file($uploadfile)) {
    $uploadfile = './' . $uploadfile;
    if (!is_file($uploadfile)) {
        exit("not find this file: " . $uploadfile_o);
    }
}
$filename = basename($uploadfile);
echo Api::getStream()->request(['method' => 'POST', 'url' => 'http://192.168.1.59:37/test_server.php', 'row' => ['Xuyuan' => 'test'], 'get' => ['get1' => 'param2', 'get2' => ['a' => 'param2a', 'b' => 'param2b']], 'post' => ['post1' => 'param2', 'post2' => ['a' => 'param2a', 'b' => 'param2b']], 'cookie' => ['cookie1' => 'param2', 'cookie2' => ['a' => 'param2a', 'b' => 'param2b']], 'file' => ['file1' => ['name' => $filename, 'value' => file_get_contents($uploadfile)]]])->getContent();