php提交過來的資料產生為txt檔案,_PHP教程

來源:互聯網
上載者:User

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檔案, 一共兩個檔案,具體連結資料庫的部分給直接去除了,前台是提交的文字部分,一行一個,在提交後另一...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.