big*_*ind 4 php put backbone.js
当backbone.js将模型保存到服务器时,它会发送PUT请求.我如何用PHP处理这些?如何获取随put请求发送的内容,并将它们存储在数据库中?
这是另一个例子:
$ values = json_decode(file_get_contents('php:// input'),true);
请参阅php文档以获取示例http://php.net/manual/en/features.file-upload.put-method.php
来自php.net:
<?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);
?>
Run Code Online (Sandbox Code Playgroud)
当您想要将数据存储到数据库时,可以将fwrite部分保留.
归档时间: |
|
查看次数: |
2759 次 |
最近记录: |