This topic is locked

How can I limit PDF file uploads?

8/15/2007 2:17:51 PM
PHPRunner General questions
F
frocco author

Hello,
How can I limit the user to just uploading PDF files?
Thanks
Frank

J
Jane 8/16/2007

Frank,
you can put this checking into generated include\commonfunctions.php file.

Find this line there:

$file_move = array($file['tmp_name'],GetUploadFolder($field).$value);


and put your checking just after.

Here is the sample code:

$ext = substr($file["name"], strlen($file["name"])-4);

$ext=strtoupper($ext);

if($ext!=".PDF")

return false;

F
frocco author 8/16/2007

Thanks Jane,
The records is still saved and no message is given.

Is there a way to prevent savign the record?
Regards,
Frank

Frank,

you can put this checking into generated include\commonfunctions.php file.

Find this line there:
and put your checking just after.

Here is the sample code:

J
Jane 8/17/2007

Frank,
also you can check file extension in the BeforeAdd event and return false if file isn't PDF.

F
frocco author 8/17/2007

Thanks Jane...
Regards,
Frank