【发布时间】:2015-04-03 14:51:05
【问题描述】:
我想使用 HTTP 将文件传输到网络服务器并以有意义的文件名保存它。我目前有传输部分工作,我需要让有意义的文件名工作。
如果我使用 Curl 传输文件,我指定要发送哪个文件:
curl -X PUT http://user:passwd@x.x.46.9/put.php --data-binary "session"
webserver上的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 地址保存文件?
非常感谢。
【问题讨论】:
-
查看此帖子stackoverflow.com/questions/14479386/… 以获取文件名解决方案。