PHP Classes

File: sample.php

Recommend this page to a friend!
  Classes of Md. Kausar Alam   File Importer   sample.php   Download  
File: sample.php
Role: Example script
Content type: text/plain
Description: example file of fileImporter class
Class: File Importer
Import data from CSV files into a MySQL database
Author: By
Last change:
Date: 14 years ago
Size: 1,048 bytes


Class file image Download
<form name="frmImportFile" enctype="multipart/form-data" method="post">
<input type="hidden" name="value" value="yes">
<table width="80%" cellpadding="0" cellspacing="0" border="0">
        <td>Import File</td>
        <td><input type="file" name="import_file" id="import_file" /><input type="submit" value="submit" /></td>
if ( $_POST['value'] == 'yes' ) {
//set the temp dir
echo $path = $_SERVER['DOCUMENT_ROOT'].'fileUploaded/temp/';
//create an object of this class
$importer = new fileImporter( $path , 'zend' , 'user' );
//create DB connection, if DB is not connected
$importer->connectDatabase( 'localhost', 'root' ,'');
//set delimiter,by defult tab
$importer->setDelimiter('comma'); //FOR COMMA,use $importer->setDelimiter('comma');
    //import file
if( $importer->importFile() ) {
'File imported successfully';
    } else {
"Error Occured!Please try again";