我從設備有一個文件(影像),其通過發送放獲取的頭信息://輸入
PUT /r.php HTTP/1.1
User-Agent: PHS/2.0.6
Host: localhost
Accept: */*
Content-Name: cam20141020084031.jpg,10001019
Content-Length: 35183
Expect: 100-continue
這是我得到的圖片,這是送:
$res = file_get_contents("php://input");
$file = fopen('1.jpg', "w");
fputs($file, $res);
fclose($file);
我也需要分別獲取內容名稱。我找不到任何地方,我怎麼能找到它。誰能幫忙?
UPDATE
$res = file_get_contents("php://input");
$vars=parse_str($res,$post_vars);
$headers = getallheaders();
$contentName=$headers['Content-Name'])
$file = fopen('1.jpg', "w");
$fileVar= fopen('1.txt', "w");
fputs($file, $res);
fputs($fileVar,$res);
fclose($fileVar);
fclose($file);
奇怪,但是這個代碼似乎永遠載入。
UPDATE 1 當我print_r它我明白,它不是標題的放置請求它的頁眉。不是我需要的。
[This](http://www.lornajane.net/posts/2008/accessing-incoming-put-data-from-php)應該有所幫助。 – Prasanth 2014-10-20 09:49:04
這不是put查詢(不是頭文件)的一些變量嗎? – 2014-10-20 09:57:41