I have this piece of PHP code here and I need it to limit the uploadable file type to .csv and size to 2 mb.
It does have file size limit but it does it in the weird way and it doesn’t limit the file extension.
What to do?
[php]<?php
$connect = mysql_connect(“localhost”,“root”,“asdasd”);
mysql_select_db(“nooruse”,$connect) or die (‘Viga andmebaasi valimisel’);
if ($_FILES[csv][size] > 0) {
$file = $_FILES[csv][tmp_name];
$handle = fopen($file,"r");
do {
if ($data[0]) {
mysql_query("INSERT INTO norse5_proov (osakond, soetusaasta, it_number, tooteruhm, mudeli_nimetus, sn, riigivara_nr, inventaari_nr, maja, ruum, vastutaja, markus, kasutajanimi) VALUES
(
'".addslashes($data[0])."',
'".addslashes($data[1])."',
'".addslashes($data[2])."',
'".addslashes($data[3])."',
'".addslashes($data[4])."',
'".addslashes($data[5])."',
'".addslashes($data[6])."',
'".addslashes($data[7])."',
'".addslashes($data[8])."',
'".addslashes($data[9])."',
'".addslashes($data[10])."',
'".addslashes($data[11])."',
'".addslashes($data[12])."'
)
") or die(mysql_error());
}
} while ($data = fgetcsv($handle,1000,",","'"));
header('Location:insert.php?success=1'); die;
}
?> [/php]