php curl文件上传没有真正的文件,想写一个字符串体

时间:2013-04-26 15:37:56

标签: php curl

您好我正在通过这个小代码上传文件

<?php
$file="oks.html";
$cookie="*;";
$csrf="*";
$parent="*";
function up($d)
{
global $cookie,$csrf,$parent;
    $ch = curl_init("https://files.one.ubuntu.com/upload/");
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_VERBOSE, 0);
    curl_setopt($ch, CURLOPT_PROXY, "127.0.0.1:8888"); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_COOKIE, $cookie);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
    curl_setopt($ch, CURLOPT_POST, true);
    $post = array(
        "csrfmiddlewaretoken"=>$csrf,
        "file"=>"@".$d.";filename=r2fas1.html;type=text/html",
        "base"=>"/files/",
        "path"=>"/",
        "parent_key"=>$parent,
        "redirct"=>"False",
        "public"=>"on",
    );
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
    $response = curl_exec($ch);
    return $response;
}
echo up($file);

但我想发送不同的文件内容有没有办法发送字符串而不是真正的文件?

0 个答案:

没有答案