PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTTP » HTTP_Upload » Bug #5445

The Packuage ignore setValidExtensions

Details

Submitted2005-09-18 09:11 UTC
Fromkay at ct-gzsz dot de
StatusBogus
PackageHTTP_Upload
PHP Version4.4.0
OSDebian 3.1
Roadmaps(Not assigned)

Comments

[2005-09-18 09:11 UTC] kay at ct-gzsz dot de

Description:
------------
The Packuage ignore setValidExtensions

I have two files test.jpg and test.png

Test script:
---------------
<?php
require 'HTTP/Upload.php';
$upload = new http_upload('de');
$chmod = $upload->setChmod(0644);
$files = $upload->getFiles();
foreach($files as $file){
$file->setValidExtensions(array('jpg'), 'accept');
if(PEAR::isError($file)){
print 'error1';
}
if($file->isValid()){
print 'valid';
}
elseif($file->isError()){
print 'error2';
}
}
?>

Expected result:
----------------
The Script print 2 times valid

but var_dump($file->_evalValidExtensions()); give me
test.jpg -> bool(true)
test.png -> bool(false)

[2005-10-22 11:02 UTC] _nospam_kag at laposte dot net

I understand isValid() as a check on file submission only: it simply means your form was correctly filled. The file treatment (eg, extension filtering) is done afterwards: does the final file creation (moving the temp file to its final location) respect the user-defined constraints. You jpg file will be created where you expect it to be, whereas your png file shouldn't.