Jump to content

Need to modify upload script to add an allowed extension


Lassie

Recommended Posts

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" );

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.