www.webdeveloper.com
Results 1 to 2 of 2

Thread: cURL and image upload

  1. #1
    Join Date
    May 2012
    Posts
    6

    Question cURL and image upload

    There is a cURL that processes the image and sends it to the server:

    PHP Code:
    if ($_POST["upload"]) {
        
    define('BASEPATH'str_replace('\\''/'dirname(__FILE__)) . '/');
        
    $upload_url $_POST["upload"];
        
    $post_params['file1'] = '@'.BASEPATH.'01.jpg';

        
    $ch curl_init();
        
    curl_setopt($chCURLOPT_URL$upload_url);
        
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
        
    curl_setopt($chCURLOPT_POSTtrue);
        
    curl_setopt($chCURLOPT_POSTFIELDS$post_params);
        
    $result curl_exec($ch);
        
    curl_close($ch);

        echo 
    $result;

    In this case it takes the path ('@'.BASEPATH.'01.jpg') to the images with strictly specified name on my server... But how to take an image through a link with a variable (../image.php?image_id='.$img.') where $img is the name/number of image? Thanx

  2. #2
    Join Date
    Oct 2007
    Posts
    371
    I'm out of practice with this specific task, but I wrote this a while back. Maybe it will help you:
    cURL multipart from data file upload.
    Last edited by TecBrat; 05-12-2012 at 01:07 PM. Reason: Change Answer.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles