Topic: Functions to prevent unwanted file types on file upload.
here, i just changed it based on my convinent for the attachements, while uploading images of a product, we dont need to allow peoples to choose, some other file types, such as doc's and exe's.
in certain case its become vulnerable to our FA. So we should avoid choosing different file types, before selecting it. Eventhough we can check it while processing form submission. but this one avoids attaching some other files type, here i changed the file_row() based on images , pdf, and doc, just try these functions,
//-----------------------------------------------------------------------------------
function kv_image_cells($label, $name, $id="")
{
if ($id != "")
$id = "id='$id'";
label_cells($label, "<input type='file' name='$name' $id accept='image/*'/>");
}
function kv_image_row($label, $name, $id = "")
{
echo "<tr><td class='label'>$label</td>";
kv_image_cells(null, $name, $id);
echo "</tr>\n";
}
//-----------------------------------------------------------------------------------
function kv_doc_cells($label, $name, $id="")
{
if ($id != "")
$id = "id='$id'";
label_cells($label, "<input type='file' name='$name' $id accept='.doc,.docx'/>");
}
function kv_doc_row($label, $name, $id = "")
{
echo "<tr><td class='label'>$label</td>";
kv_doc_cells(null, $name, $id);
echo "</tr>\n";
}
//-----------------------------------------------------------------------------------
function kv_pdf_cells($label, $name, $id="")
{
if ($id != "")
$id = "id='$id'";
label_cells($label, "<input type='file' name='$name' $id accept='.pdf'/>");
}
function kv_pdf_row($label, $name, $id = "")
{
echo "<tr><td class='label'>$label</td>";
kv_pdf_cells(null, $name, $id);
echo "</tr>\n";
}
HRM CRM POS batch Themes