| |
|
|
| | хотел написать отправку файла картинки на imageshack.us с помошью сокетов
а сервер выдает 400 - BAD REQUEST
статью читал (http://softtime.ru/scripts/post_copy.php)
не особо понял...
в чем ошибка здесь?
<?php
function send_pic( $pic = "/usr/public_html/pic.jpg" )
{
$host = "www.imageshack.us";
$path = "/";
$fp = fsockopen( $host,80,$errno,$errstr,30 );
if (!$fp)
{
echo $errstr." (".$errno.")";
exit;
}
$headers = "POST ".$path." HTTP/1.1\r\n";
$headers .= "Host: $host\r\n";
$headers .= "Referer: ".$host."\r\n";
$headers .= "Content-Disposition: form-data; name=\"fileupload\"; filename=\"".$pic."\"\r\n";
$headers .= "Content-length: ".strlen($fileHeaders) + filesize($pic)."\r\n";
$headers .= "Content-Type: image/jpeg\r\n\r\n";
fwrite($fp,$headers);
$text = "";
while(!feof($fp)) $text .= fgets($fp,4096);
fclose($fp);
return $text;
}
echo send_pic();
?>
|
| |
| |
|
|
| |
|
|
| |
для: 1999
(04.11.2006 в 14:08)
| | | Отправка файлов методом POST имеет немного другой формат. Подробности в теме по ссылке [url]ttp://www.softtime.ru/forum/read.php?id_forum=1&id_theme=1324 [/url]. | |
| |
|
|