Presentasi sedang didownload. Silahkan tunggu

Presentasi sedang didownload. Silahkan tunggu

Bayu Priyambadha, S.Kom.  PHP provide some functions to manage file, likes :  Open / Close  Write / Read  Add / append  Fopen = for open file  Fget.

Presentasi serupa


Presentasi berjudul: "Bayu Priyambadha, S.Kom.  PHP provide some functions to manage file, likes :  Open / Close  Write / Read  Add / append  Fopen = for open file  Fget."— Transcript presentasi:

1 Bayu Priyambadha, S.Kom

2  PHP provide some functions to manage file, likes :  Open / Close  Write / Read  Add / append  Fopen = for open file  Fget = for get entire file

3 ModeKeterangan r Membuka file untuk proses pembacaan (reading) r+ Membuka file untuk proses pembacaan (reading) dan penulisan w Membuka file untuk proses penulisan (writing) w+ Membuka file untuk proses penulisan dan pembacaan. a Membuka file untuk proses penambahan data (appending) a+Membuka file untuk proses pembacaan dan penambahan data.

4 <? $file = “contoh.txt”; $fp = fopen($file, “r”); while (!feof($fp)) { $baris = fgets($fp, 1024); echo $baris.” ”; } fclose($fp); ?>

5 <? $file = “contoh.txt”; $fp = fopen($file, “r”); while (!feof($fp)) { $baris = fread($fp, 30); echo $baris; } fclose($fp); ?>

6 <? $file = “contoh.txt”; $fp = fopen($file, “w”); fwrite($fp, “Menuliskan ke dalam file”); fclose($fp); $fp = fopen($file, “a”); fputs($fp, “Menambahkan ke dalam file”); fclose($fp); $fp = fopen($file, “r”); while (!feof($fp)) { $baris = fgets($fp, 1024); echo $baris; } fclose($fp); ?>

7  Use enctype="multipart/form-data" on html form  Use with type=“file”  $_FILES[field name][atribut] to get file  Atribute :  tmp_name = temporary path where the file will be placed  name = file name  move_uploaded_file() or copy() for move file from temporary path to real destination

8 <?php $user_file = $_FILES[“file_user”][“tmp_name”]; $filename = $_FILES[“file_user”][“name”]; $tujuan = “”; copy($user_file, $tujuan.$filename); ?>

9


Download ppt "Bayu Priyambadha, S.Kom.  PHP provide some functions to manage file, likes :  Open / Close  Write / Read  Add / append  Fopen = for open file  Fget."

Presentasi serupa


Iklan oleh Google