Hello
Im trying to use imageshshack api in php
in the following way:
<?php
function do_post_request($url, $data, $optional_headers = null) {
$params = array('http' => array(
'method' => 'POST',
'content' => $data
));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $url, $php_errormsg");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from $url, $php_errormsg");
}
return $response;
}
$fileName = $_FILES['picture']['name'];
$tmpName = $_FILES['picture']['tmp_name'];
$fileSize = $_FILES['picture']['size'];
$fileType = $_FILES['picture']['type'];
$fo = @fopen($tmpName, "r");
$imgposted = @fread($fo, filesize($tmpName));
$imgposted = addslashes($imgposted);
$data = 'fileupload='.$imgposted.'&rembar=1&key=******';
echo do_post_request('http://www.imageshack.us/upload_api.php',$data);
?>
but the data is being posted normally, I wanted to be posted like if I had a form with this attribute:
enctype="multipart/form-data"
any solution?