Lassie Posted January 22, 2013 Share Posted January 22, 2013 upload.phpI want to modify a script to add pdf as an allowable extension. I have tried modifying the array of the $allowable extensions but pdf files are still rejected on upload. Is there anything else in this script I need to modify? these seem to be relevant parts line 62 class qqFileUploader { private $allowedExtensions = array(); private $sizeLimit = 10485760; private $file; function __construct(array $allowedExtensions = array(), $sizeLimit = 10485760){ $allowedExtensions = array_map("strtolower", $allowedExtensions); $this->allowedExtensions = $allowedExtensions; $this->sizeLimit = $sizeLimit; line 134 $pathinfo = pathinfo($this->file->getName()); $filename = $pathinfo['filename']; //$filename = md5(uniqid()); $ext = $pathinfo['extension']; if($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)){ $these = implode(', ', $this->allowedExtensions); return array('error' => 'File has an invalid extension, it should be one of '. $these . '.');// list of valid extensions, ex. array("jpeg", "xml", "bmp") line 162 $allowedExtensions = array( "jpeg", "jpg", "png", "gif", "mp3", "ogg", "mp4", "webm", "ogv","pdf" ); Quote Link to comment https://forums.phpfreaks.com/topic/273494-need-to-modify-upload-script-to-add-an-allowed-extension/ Share on other sites More sharing options...
Jessica Posted January 22, 2013 Share Posted January 22, 2013 Why are you defining the allowed extensions way after trying to use it? Quote Link to comment https://forums.phpfreaks.com/topic/273494-need-to-modify-upload-script-to-add-an-allowed-extension/#findComment-1407520 Share on other sites More sharing options...
PFMaBiSmAd Posted January 22, 2013 Share Posted January 22, 2013 What exact symptom or error do you get the leads you to believe that pdf files are rejected? Quote Link to comment https://forums.phpfreaks.com/topic/273494-need-to-modify-upload-script-to-add-an-allowed-extension/#findComment-1407522 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.