php提交過來的資料產生為txt檔案,
一共兩個檔案,具體連結資料庫的部分給直接去除了,前台是提交的文字部分,一行一個,在提交後另一個程式檔案進行處理,然後按照提交的檔案名稱產生相應的txt 檔案,並在txt 檔案中加入資料,在使用之前需要先在根目錄下建立 test 檔案下。
前台表單檔案如下(儲存為dcwz.php):
<?phperror_reporting(0);//require_once("../config.php");//require_once("../admin/ly_check.php");//$sql="select * from leibie";//$rs=mysql_query($sql);?>無標題文檔
產生 txt 檔案的處理常式如下所示(儲存為dcwj_cl.php):
<?php$biaoti_cl=explode("\n",$biaoti);$biaoti_num=count($biaoti_cl); $file_type = "txt"; for($i=0;$i<$biaoti_num;$i++){ $file_name = mb_convert_encoding($biaoti_cl[$i],'GBK',"UTF-8"); $data[] = array("tom","boy",20); $dir=dirname(__FILE__)."\\text\\"; $string = ""; foreach($data as $k =>$v){ foreach($v as $vstr){ $string .= mb_convert_encoding($vstr,'GBK',"UTF-8"); } } $string .="\r\n"; $filedir = $dir.trim($file_name).".".$file_type; $fileurl = str_replace('',' ',$filedir); $fp = fopen($fileurl,"a+"); echo '建立'.$fileurl.'
'; fwrite($fp,$string); fclose($fp); } ?>
以上就是本文的全部內容,希望對大家學習php程式設計有所協助。
http://www.bkjia.com/PHPjc/1125262.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1125262.htmlTechArticlephp提交過來的資料產生為txt檔案, 一共兩個檔案,具體連結資料庫的部分給直接去除了,前台是提交的文字部分,一行一個,在提交後另一...