Hi all,
I want to update/insert file by using upload box to the database but before that it will check for the file type thats only pdf can be upload. Somthing wrong with the codes and i dont know what..Please help
here are part of my updates codes:
$id=$rs['id'];
$qry = "SELECT a.faillampiran FROM {$CFG->prefix}ptk_lampiran a, {$CFG->prefix}ptk b WHERE a.ptkid=$id and b.id=$id";
$sql = get_records_sql($qry);
if($_POST['check']){
$ext = pathinfo($faillampiran,PATHINFO_EXTENSION);
$err = "Upload Only PDF File. ";
if ($ext =='pdf'){
$qry="UPDATE {$CFG->prefix}ptk_lampiran SET
faillampiran='".$faillampiran."'
WHERE ptkid='".$_GET['id']."'";
$sql=mysql_query($qry);
$qry = "SELECT a.faillampiran FROM {$CFG->prefix}ptk_lampiran a, {$CFG->prefix}ptk b
WHERE b.id = '".$rs[id]."' AND a.ptkid = '".$rs[id]."' ";
$sql = get_records_sql($qry);
foreach($sql as $rs){ ?>
<?=basename($rs->faillampiran); ?><br>
<? }
?>
<tr><td></td><td></td><td>
<input type="file" size="50" name="faillampiran" alt="faillampiran" value= "<?=$faillampiran;?>" />
<input type="submit" name="edit" value="Muat naik fail ini" /><br />
</td></tr>
}
else {
echo "<script>alert('$err')</script>";
}
} else {
foreach($sql as $rs){ ?>
<?=basename($rs->faillampiran); ?><br>
<? }
?>
<input type="file" size="50" name="faillampiran" alt="faillampiran" value= "<?=$faillampiran;?>" />
<input type="submit" name="edit" value="Muat naik fail ini" /><br />
<?}
Sori bout the messiness of the codes, im still a beginner in this languages.
thx