0
我想使用HTTP將文件傳輸到網絡服務器並將其保存爲有意義的文件名。我目前有傳輸部分工作,我需要做有意義的文件名工作。HTTP PUT到PHP中的唯一文件名
如果我使用捲曲傳輸文件,我指定要發送的文件:
捲曲-X PUT http://user:[email protected]/put.php --data二進制「會話」
在Web服務器上的PHP腳本如下:
/* PUT data comes in on the stdin stream */
$putdata = fopen("php://input", "r");
/* Open a file for writing */
$fp = fopen("myputfile.ext", "w");
/* Read the data 1 KB at a time
and write to the file */
while ($data = fread($putdata, 1024))
fwrite($fp, $data);
/* Close the streams */
fclose($fp);
fclose($putdata);
?>
有沒有辦法提取在HTTP PUT消息中發送的文件名並將其用於文件名?或者,至少,有沒有辦法使用源設備的IP地址保存文件?
非常感謝。
檢查這個帖子http://stackoverflow.com/questions/14479386/how-to-get-filename-in-php-in-put-request輸入文件名解。 – AndreiDMS 2015-04-03 15:02:08