Contoh script membaca file import (txt file)

<?
/*
File ini akan mengambil text files dan menampilkannya di layar
*/
if ($_POST[Submit]==”Import”) {
$fd = fopen($_FILES[“userfile”][“tmp_name”],”r”);
while (!feof($fd)) {
$buffer     = fgets($fd, 4096);
$tmp_data    = split(“\t”, $buffer);
for ($i=0; $i<count($tmp_data); $i++) {
echo $tmp_data[$i].” – “;
}
echo “<br>”;
}
}
?>
<form enctype=”multipart/form-data” method=”post”>
<table>
<tr>
<td>Nama File </td>
<td><input type=”file” name=”userfile”></td>
</tr>
<tr>
<td colspan=”2″><input type=”submit” name=”Submit” value=”Import”></td>
</tr>
</table>
</form>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: