HTTP_Upload
| From: | Tomek Klas | Date: | Sat, 31 Jul 2004 23:44:34 +0000 |
| Subject: | HTTP_Upload | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-13927@lists.php.net to get a copy of this message | ||
Hello,
I have started using PEAR a couple of weeks ago and it's great, but..
I am using HTTP_Upload and it does the job no problems, but I was wondering about that isValid() function. There is a lot of error_codes, but how do I set the parameters such as max size or valid extensions, to trigger TOO_LARGE and NOT_ALLOWED_EXTENSION ? I want to stop people from uploading strange, excessively large files...
Sorry if it's an easy question, I am a beginner ;)
Below sample of my code...
Tomek
if ( !empty($_FILES['abstract_pic_filename']['name']) ) {
// upload the abstract image if exists
$upload_abstract_image = new HTTP_Upload();
$abstract_file = $upload_abstract_image->getFiles('abstract_pic_filename');
// Check if the file is a valid upload
if ($abstract_file->isValid()) {
$mode = 'uniq';
$prepend = '';
$append = '';
$abstract_file->setName ($mode, $prepend, $append);
$file_name = $abstract_file->moveTo("/Users/$real_user/Sites/site_images/en/");
$properties = $abstract_file->getProp();
}
}