Re: Document Upload File Type Validation
Thanks for the help Bartho.
Tried that, but the file seems to upload anyway. Which field in the form should I check?
Here is the problem.
If I am inserting this into the database (BLOB), the file upload field does an automatic AJAX process when I browse for the file to upload. The field blinks for a second than is blank. During this process SC appears to be extracting the filename and file size, because SC requires file name and file size fields in the DB. I created these and SC automatically extracts the file name and file size from the file upload field and writes them to the DB like this:
id|document(BLOB)|filename(file name)|filesize
Here is what I tried and it didn’t work.
$whitelist = array('jpg', 'png', 'gif', 'jpeg', 'doc', 'pdf'); #example of white list
if(!in_array(end(explode('.', {document})), $whitelist))
{
echo 'Invalid file type';
exit(0);
}