用fwrite函数,手册上的例子: <?php $filename = 'test.txt'; $somecontent = "Add this to the file\n";// Let's make sure the file exists and is writable first. if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success, wrote ($somecontent) to file ($filename)"; fclose($handle);} else { echo "The file $filename is not writable"; } ?>
换种方式吧。或者把需求描述清楚些
<?php
$filename = 'test.txt';
$somecontent = "Add this to the file\n";// Let's make sure the file exists and is writable first.
if (is_writable($filename)) { // In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
} // Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
} echo "Success, wrote ($somecontent) to file ($filename)"; fclose($handle);} else {
echo "The file $filename is not writable";
}
?>
本地还是服务器。
放在服务器的话,似乎就不行了。本地运行的话,可以用ftp的方式,发送到服务器。
或者在服务器 做个上传接口。
你在本地调用,把图片数据发送过去,服务器端保存。
先决条件是你在本地执行php程序
本地模拟客户端把文件读出来,发送过去.这两个文件要比对密钥,只有你自己知道.