Dear all i have a problem, how to do this with sql/php i have the following table structure. how to allow PHP upload file to upload only these extension having their respective size.
$filetype = $_FILES['filefield']['type']; $q= ("select * from yourtablename where extension='$filetype' limit 1"); $res= mysql_query($q) or die(mysql_error()); if (mysql_num_rows($res)==0) { //it means file type not present in your table echo "File type not allowed !"; } else { //this size is in byte, to use Kb or MB divide it ot 1024. example for mb : $mbfilesize = ($_FILES['filefield']['size']/1024)/1024; $filesize = $_FILES['filefield']['size']; while ($row=mysql_fetch_assoc($res)) { $tblsize = $row['size']; } if ($filesize>$tblsize) { echo "Maximum file size allowed : ".$tblsize;} else { //continue upload } } Code (markup): hope this helps you get the idea!