Location: PHPKode > projects > SQLite PHP Admin > spa/import.php
<?php
/***********************************************************************

		Copyright (c) 2011, Andrew V. Pleshakov	(hide@address.com)
		All rights reserved.

		This file is part of SPA (SQLite PHP Admin)
		See file LICENSE.txt for details

************************************************************************/

require_once('include.php');
if(!$pla_db) {
	header('Location: main.php');
	die;
}
if(!isset($_FILES['file']))
	die(design_render('db/import',$tar));

$sql ="<br />\n<table>\n";

if($_FILES['file']['error'] != UPLOAD_ERR_OK) {
	// ERROR UPLOADING FILE
	$sql .= design_render('misc/sqle',array('err'=>$pla_db->error));
}
else {
	$exsql = file_get_contents($_FILES['file']['tmp_name']);
	$exsql = iconv(DEF_CHARSET,$encoding,$exsql);
	if($pla_db->exec($exsql)) {
		$time_tot = round(microtime(true) - $time_start,5);
		$rows_affected = $pla_db->affectedRows();
		$rows_returned = 0;
		$sql .= design_render('misc/sqlr',array('affected'=>$rows_affected,'returned'=>$rows_returned,'total'=>$time_tot));
		$sql .= '<tr><td>&nbsp;</td></tr>';
	}
	else
		$sql .= design_render('misc/sqle',array('err'=>$pla_db->error));
}

$tar['sql'] = $sql;
die(design_render('query',$tar));
Return current item: SQLite PHP Admin