我想使用HTTP将文件传输到Web服务器,并用有意义的文件名保存。我目前有传输部分在工作,我需要使有意义的文件名部分工作。
如果我使用Curl传输文件,我会指定要发送的文件:
卷曲-X PUThttp://user:passwd@x.x.46.9/put.php--数据二进制"会话"
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地址保存文件?
非常感谢。