7

Hi i am uploading files by this little code

<?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);

but i want to send different file content is there a way to send string than real file ?

3
  • Possible duplicate of stackoverflow.com/questions/3085990/… Commented Apr 26, 2013 at 15:48
  • these answers may be solutions for put requests but normal post request Commented Apr 26, 2013 at 16:09
  • These are the answers for post requests too (you have to set up the whole post data manually). The only other option is to use temporary files. Commented Apr 26, 2013 at 17:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.