";
//moguce greske
error_reporting(E_ALL);
ini_set('display_errors', 1);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = $_FILES['uploadFile']['name'];
$tmpName = $_FILES['uploadFile']['tmp_name'];
$error = $_FILES['uploadFile']['error'];
$size = $_FILES['uploadFile']['size'];
$ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
switch ($error) {
case UPLOAD_ERR_OK:
$valid = true;
//validate file extensions
if ( !in_array($ext, array('csv')) ) {
$valid = false;
$response = 'Nedozvoljen tip datoteke.';
echo $response;
exit;
}
//validate file size
if ( $size/1024/1024 > 2 ) {
$valid = false;
$response = 'File size is exceeding maximum allowed size.';
}
//upload file
if ($valid) {
// $targetPath = dirname( __FILE__ ) . DIRECTORY_SEPARATOR. 'uploads' . DIRECTORY_SEPARATOR. $name;
// move_uploaded_file($tmpName,$targetPath);
// header( 'Location: index.php' ) ;
// exit;
$response = 'Datoteka je ucitana.';
}
break;
case UPLOAD_ERR_INI_SIZE:
$response = 'Velicina datoteke je veca od dozvoljene.';
break;
case UPLOAD_ERR_PARTIAL:
$response = 'The uploaded file was only partially uploaded.';
break;
case UPLOAD_ERR_NO_FILE:
$response = 'Datoteka nije ucitana.';
break;
case UPLOAD_ERR_NO_TMP_DIR:
$response = 'Nedostaje TMP folder. Introduced in PHP 4.3.10 and PHP 5.0.3.';
break;
default:
$response = 'Nepoznata greska';
break;
}
echo $response."
";
echo "informacije o datoteci:";
echo "
".$csv[$row][$col]." | "; } echo "