将文本框中内容保存到txt文本中 在文本框中保存了一些图片的地址,要将它生成txt文件保存到本地,怎么做哦!给点例子啊,还有解释 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 function write2file($msg,$fileName){ $fp = @fopen($fileName, 'a'); if($fp==false) { $fp=@fopen($fileName,'w+'); if($fp==false) { echo " file ".$fileName." can not be created for writing"; return 0; } } $lfp = flock($fp,LOCK_EX); $i = 0; while ($lfp == False) { $i++; $lfp = flock($fp,LOCK_EX); if ($i==10){return(0);} } fputs($fp,$msg); flock($fp,LOCK_UN); fclose($fp); return 1;} $msg是接收的文本框中的值$fileName是你要放的txt文本的文件路径 好了啊,谢谢各位,发个源码大家在给点建议。if($mesh->post["type"]=="1")//存储文件。{ $model=1; require_once('splash/model'.$model.'/model.php'); $data= $mesh->db->FindById('net_splash',$netid,"netid"); $mode= new model(); $html=$mode->parse_echo($data->content);//////////////////////////////////////////////////// saveFiles(SPLASH_DIR.$netid.".txt",$html);//保存splash页面的html代码, $cmd=array(); $cmd[]="page ".WWW_URL."splash/".$netid.".txt"; foreach($mode->images as $value){ $cmd[]="image ".WWW_URL.$value; } /* * $cmd[]=? 从数据库把用户定义的图片资源拿出来,images/bg.jpg */ $cmd[]="image ".WWW_URL.$data->images; saveFiles(SPLASH_DIR.$netid.".page",implode("\r\n",$cmd));//splash.page的所有命令。}function saveFiles($filename,$content){ if($fp = fopen($filename, "w")) { if(!fwrite($fp,$content,strlen($content))) { fclose($fp); return false; } fclose($fp); return true; }else return false;} 首先获取文本框里的内容,再将内容POST到对应的处理程序,再生成文件即可 求一套 免费可自定义的 进销存 PHP 开发企业建站系统【木子建站系统】 开源 求一个随机数的算法 用哪家的短信接口 熟悉了ecshop能做什么? 感觉就是一个很基本的东西。。。 哈哈oschina自己搞代码托管了,呵呵 php nginx fastdfs 下载文件重命名 织梦CMS 联动类型不显示 求apache配置虚拟主机 查错 ThinkPHP链接数据库问题 PHP的中文在线手册及如何参与PHP文档的中文翻译 windows server 2003+IIS6+fastCGI+php5.3.2的问题
{
$fp = @fopen($fileName, 'a');
if($fp==false)
{
$fp=@fopen($fileName,'w+');
if($fp==false)
{
echo " file ".$fileName." can not be created for writing";
return 0;
}
}
$lfp = flock($fp,LOCK_EX);
$i = 0;
while ($lfp == False)
{
$i++;
$lfp = flock($fp,LOCK_EX);
if ($i==10){return(0);}
}
fputs($fp,$msg);
flock($fp,LOCK_UN);
fclose($fp);
return 1;
}
$fileName是你要放的txt文本的文件路径
if($mesh->post["type"]=="1")//存储文件。
{
$model=1;
require_once('splash/model'.$model.'/model.php');
$data= $mesh->db->FindById('net_splash',$netid,"netid");
$mode= new model();
$html=$mode->parse_echo($data->content);////////////////////////////////////////////////////
saveFiles(SPLASH_DIR.$netid.".txt",$html);//保存splash页面的html代码,
$cmd=array();
$cmd[]="page ".WWW_URL."splash/".$netid.".txt";
foreach($mode->images as $value){
$cmd[]="image ".WWW_URL.$value;
}
/*
* $cmd[]=? 从数据库把用户定义的图片资源拿出来,images/bg.jpg
*/
$cmd[]="image ".WWW_URL.$data->images;
saveFiles(SPLASH_DIR.$netid.".page",implode("\r\n",$cmd));//splash.page的所有命令。
}function saveFiles($filename,$content)
{
if($fp = fopen($filename, "w"))
{
if(!fwrite($fp,$content,strlen($content)))
{
fclose($fp);
return false;
}
fclose($fp);
return true;
}else
return false;
}
首先获取文本框里的内容,再将内容POST到对应的处理程序,再生成文件即可