How can I check if uploading a PDF file is password protected or not while uploading multiple files using PHP? I want to show an error if it's password protected.
2条回答 默认 最新
- douxiaomang5640 2013-04-09 12:07关注
i found a similiar post on the web check it out.
/** * Check whether pdf is encrypted or password protected. * @param <type> $form * @param <type> $form_state */ function pdftest_is_encrypted($form,&$form_state) { include_once 'sites/all/libraries/fpdi/pdf_parser.php'; foreach($form_state['values']['files'] as $value) { //Check whether file type is pdf and confirm the file is selected to remove. if($value['filemime'] == 'application/pdf' && $value['remove'] != 1) { $pdf = new pdf_parser($value['filepath']); if(stristr($pdf->errormsg,'File is encrypted')) { form_set_error('field_attachment', t('Uploaded PDF Document '.$value['filename'].' is encrypted and can not be uploaded. '.l('Guide to troubleshooting failed uploads.','http://support.scribd.com/forums/33627/entries/24412'))); } } }
解决 无用评论 打赏 举报
悬赏问题
- ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
- ¥15 cmd cl 0x000007b
- ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
- ¥500 火焰左右视图、视差(基于双目相机)
- ¥100 set_link_state
- ¥15 虚幻5 UE美术毛发渲染
- ¥15 CVRP 图论 物流运输优化
- ¥15 Tableau online 嵌入ppt失败
- ¥100 支付宝网页转账系统不识别账号
- ¥15 基于单片机的靶位控制系统