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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.