使用cURL将带有PHP的文件上传到ima​​geshack

I am trying to upload a file to imageshack using following script:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://post.imageshack.us/');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_POST, true);
$post = array(
    'fileupload'=> '@../../resources/images/cancel.png',
    'optsize' => 'resample',
    'rembar' => '1'
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
curl_close($ch);

echo $response;

However, I get following error from imageshack:

Wrong file type detected for file cancel.png:application/octet-stream.

Why is that, and how can it be fixed? Thanks in advance!

EDIT: It does work when I use JPGs or GIFs (even animated ones, although Imageshack then de-animates them, I think by only using the first frame), but not with PNGs.

EDIT 2: I found out how to fix it. As stated earlier, it does only accept JPGs and GIFs. So I take the location of the image I need to upload, copy it to a temporary location with the ending .jpg, upload the file, and then, upon completion, I remove the file from the temporary location.

Set the Content-type to the type of the file.

According to the manual, it must be an array or object. So here

$arr = array('Content-type: text/plain') ;
curl_setopt ( $ch , CURL_HTTPHEADER , $arr );