I have a query I use to insert data and text into my DB. The script provides the validation for the file size not type is assigned, how do I add the file type validation to this script. Could someone point to some material that will help me out of the jam?
[PHP]
// Connect to database
$errmsg = "";
if (! @mysql_connect("#","#","#")) {
$errmsg = "Cannot connect to database";
}
@mysql_select_db("000000");
// First run ONLY - need to create table by uncommenting this
// Or with silent @ we can let it fail every sunsequent time ;-)
@mysql_query($q);
// Insert any new image into database
if ($_REQUEST[completed] == 1) {
// Need to add - check for large upload. Otherwise the code
// will just duplicate old file ;-)
// ALSO - note that latest.img must be public write and in a
// live appliaction should be in another (safe!) directory.
move_uploaded_file($_FILES['imagefile']['tmp_name'],"latest.img");
$instr = fopen("latest.img","rb");
$image = addslashes(fread($instr,filesize("latest.img")));
if (strlen($instr) < 149000) {
mysql_query ("insert into pix (whatsit, imgdata, firstname, lastname, address) values (\"".
$_REQUEST[whatsit].
"\", \"".
$image.
"\", \"".
$_REQUEST[firstname].
"\", \"".
$_REQUEST[lastname].
"\", \"".
$_REQUEST[address].
"\")");
mysql_query($query) or die('Account Created redirecting please wait... <meta http-equiv="refresh" content="3;URL=#">');
} else {
$errmsg = "Too large!";
}
}
[/PHP]
Thanks In advance!