CURL Upload problems :(

Discussion in 'PHP' started by ps3ubo, Nov 15, 2009.

  1. #1
    I have tryed for over 4 million years now to do this.. ARRRG!

    I am trying to make a upload script.. but something is wrong with it...

    Anything wrong with it?

    I guess the problem is:
    curl_setopt($ch, CURLOPT_POSTFIELDS, array("
    [MAX_FILE_SIZE] => 157286400,
    [quick_upload_submit] => OK,
    [file] => array([name] => ".$_FILES['file']['name'].",
    [type] => ".$_FILES['file']['type'].",
    [tmp_name] => ".$_FILES['file']['tmp_name'].",
    [size] => ".$_FILES['file']['size'].")
    "));

    ????

    <form id="form_upload_submit" method="POST" enctype="multipart/form-data">
    <input type="hidden" name="MAX_FILE_SIZE" value="157286400" />
    <input type="file" name="file" id="file" size="14" />
    <input type="submit" name="quick_upload_submit" value="OK" />
    </form>
    
    <?php
    if($_POST){
    
    $url = "http://www.wrzuta.pl/pliki/dodaj";
    
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    
    curl_setopt($ch, CURLOPT_POSTFIELDS, array("
    [MAX_FILE_SIZE] => 157286400,
    [quick_upload_submit] => OK,
    [file] => array([name] => ".$_FILES['file']['name'].",
    [type] => ".$_FILES['file']['type'].",
    [tmp_name] => ".$_FILES['file']['tmp_name'].",
    [size] => ".$_FILES['file']['size'].")
    "));
    
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $res = curl_exec($ch);
    echo $res;
    curl_close($ch);
    }
    ?>
    PHP:
    Thanks for your help dudes :)
     
    ps3ubo, Nov 15, 2009 IP
  2. ps3ubo

    ps3ubo Peon

    Messages:
    204
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Also out of interest.. with a upload of a file.. is there away to let me upload it from a URL not a file from my computer?

    Thanks again...
     
    ps3ubo, Nov 15, 2009 IP
  3. zinghana

    zinghana Well-Known Member

    Messages:
    1,970
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    125
    #3
    Hi,

    Have a look here, http://www.uploadphpscript.net/ this is a great tutorial for an upload script, worked for me 1st go and i never looked into making an upload script before....

    Good luck
     
    zinghana, Nov 15, 2009 IP
  4. ps3ubo

    ps3ubo Peon

    Messages:
    204
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks, but this is not what I need, I need the CURL uploader...
    To remotly upload to someones website...
     
    ps3ubo, Nov 15, 2009 IP
  5. ps3ubo

    ps3ubo Peon

    Messages:
    204
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Theres gotta be away?!
     
    ps3ubo, Nov 15, 2009 IP
  6. zinghana

    zinghana Well-Known Member

    Messages:
    1,970
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    125
    #6
    I know there are 3rd party scripts, but that kind of programming is not my best area, only trying to help, Good Luck
     
    zinghana, Nov 15, 2009 IP
  7. szalinski

    szalinski Peon

    Messages:
    341
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #7
    as far as i'm aware, you don't use curl to process an incoming upload. it looks like you want to send a file from your pc to your php script. so you should use the $_FILES info on its own to process the posted form data. see the php.net site for an example upload script.

    if you wanted to upload a file that exists on your server, to another server, then you'd use curl.
     
    szalinski, Nov 20, 2009 IP