【问题标题】:HTTP PUT to unique filename in PHPHTTP PUT 到 PHP 中的唯一文件名
【发布时间】: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 地址保存文件?

非常感谢。

【问题讨论】:

标签: php html curl put


【解决方案1】:

是的,您拥有所有这些信息in the $_REQUEST variable.

【讨论】:

    猜你喜欢
    • 2010-10-02
    • 2010-12-14
    • 1970-01-01
    • 2012-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-29
    相关资源
    最近更新 更多