Hi! I am trying to upload images to teambox.com using curl and php, but I always get the error "Invalid file name", "you can't upload a blank file", and "Invalid Record".
Any suggestions on how to fix it?

here's my code:

$fields = array(
    'file' => file_get_contents($_FILES['upload_field_'.$task_id]['tmp_name'])
);

$fields_string = http_build_query($fields);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_POSTFIELDS,$json_string);

$http_result = curl_exec($ch);
$error       = curl_error($ch);
$http_code   = curl_getinfo($ch ,CURLINFO_HTTP_CODE);

curl_close($ch);

The API states you need to pass 4 parameters, and none of them is named 'file'. In line 13 you use $json_string but it isn't defined anywhere.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.