Changeset 356
- Timestamp:
- 03/20/06 14:17:48 (2 years ago)
- Files:
-
- trunk/autopackage.php (modified) (1 diff)
- trunk/package.php (modified) (1 diff)
- trunk/patForms/Element/File.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/autopackage.php
r352 r356 45 45 - File: determining the session's save path now correctly uses the php.ini setting if available (argh) 46 46 - File: improved error messages with useful information and error solving hints (argh) 47 - File: fixed the notice that occurrs when the maxsize attribute is not set (argh) 47 48 48 49 * Rules trunk/package.php
r352 r356 55 55 - File: determining the session's save path now correctly uses the php.ini setting if available (argh) 56 56 - File: improved error messages with useful information and error solving hints (argh) 57 - File: fixed the notice that occurrs when the maxsize attribute is not set (argh) 57 58 58 59 * Rules trunk/patForms/Element/File.php
r355 r356 308 308 /** 309 309 * initialze file elemente 310 * 310 * 311 311 * - check temporary file upload dir required when sessions are used 312 312 * - check file upload in php.ini 313 * 313 * 314 314 * @access private 315 315 * @return mixed $success True on success, a patError object otherwise … … 322 322 'php.ini doesn\'t allow file upload see: "file_uploads"' ); 323 323 } 324 324 325 325 // require temporary directory if session-support is switched on 326 326 if( $this->useSession() ) … … 328 328 // store the required flag for easy access 329 329 $tempdir = $this->attributes['tempdir']; 330 330 331 331 // use php.ini default 332 332 if( empty( $tempdir ) ) { … … 336 336 } 337 337 } 338 338 339 339 if( !is_dir( $tempdir ) && !is_writeable( $tempdir ) ) { 340 $error = patErrorManager::raiseError( 340 $error = patErrorManager::raiseError( 341 341 PATFORMS_FILE_ERROR_TEMPDIR_NOT_VALID, 342 342 'Session support is on but cannot work', … … 346 346 'is set to "'.$this->getAttribute( 'tempdir' ).'".' 347 347 ); 348 348 349 349 return $error; 350 350 } 351 351 352 352 $this->tempdir = $tempdir; 353 353 } … … 359 359 'Destination folder "' . $this->attributes['uploaddir'] . '" does not exist or is not writeable!' ); 360 360 } 361 361 362 362 return true; 363 363 } … … 393 393 } 394 394 395 $this->attributes["name"] = $name; 395 $this->attributes["name"] = $name; 396 396 $valueElement = $this->createHiddenTag( $this->attributes["value"] ); 397 397 /* … … 443 443 $empty = false; 444 444 $mime = false; 445 $uploade = false; 445 $uploade = false; 446 446 447 447 $error = UPLOAD_ERR_NO_FILE; … … 451 451 if( isset( $_FILES ) ) { 452 452 $files = $_FILES; 453 453 454 454 if( ( $namespace = $this->getNamespace() ) && isset( $files[$namespace] ) ) { 455 455 $files = $files[$namespace]; 456 456 } 457 457 } 458 458 459 459 // file was just uploaded 460 460 if( !empty( $files ) && ( isset($files[$nameUpload] ) || isset( $files['name'][$nameUpload] ) ) ) { … … 499 499 if( $oldfile = $this->getSessionValue( 'uploadfile' ) ) { 500 500 unlink( $oldfile ); 501 } 501 } 502 502 } 503 503 … … 510 510 return false; 511 511 } 512 513 if( $size > $this->attributes['maxsize'] ) { 512 513 $maxsize = $this->getAttribute( 'maxsize' ); 514 if( $maxsize && $size > $this->attributes['maxsize'] ) { 514 515 $this->addValidationError( 3, array( 'maxsize' => $this->attributes['maxsize'] ) ); 515 516 return false; … … 585 586 if( $this->useSession() && !$restored ) { 586 587 $tempfile = tempnam( $this->tempdir, $name . '_' ); 587 588 588 589 if( !move_uploaded_file( $uploadFile, $tempfile ) ) { 589 590 return patErrorManager::raiseError( PATFORMS_FILE_ERROR_CANNOT_MOVE_UPLOAD_FILE, … … 636 637 $files = $files[$namespace]; 637 638 } 638 639 639 640 if( isset( $files[$nameUpload]["tmp_name"] ) ) { 640 641 $uploadFile = $files[$nameUpload]["tmp_name"]; 641 } 642 } 642 643 else if( isset( $files["tmp_name"][$nameUpload] ) ) { 643 644 $uploadFile = $files["tmp_name"][$nameUpload]; … … 649 650 return true; 650 651 } 651 652 652 653 // cannot use 'move_upload_file()' in case of usage of sessions 653 654 if( !rename( $uploadFile, "$dir/$value" ) ) { 654 $error = patErrorManager::raiseError( 655 $error = patErrorManager::raiseError( 655 656 PATFORMS_FILE_ERROR_CANNOT_MOVE_UPLOAD_FILE, 656 657 "Cannot upload file", 657 "Could not move file '".$uploadFile."' to '".$dir."/".$value."'" 658 "Could not move file '".$uploadFile."' to '".$dir."/".$value."'" 658 659 ); 659 660 660 661 return $error; 661 662 } 662 663 663 664 chmod( "$dir/$value", $this->_getPermission() ); 664 665 return true; … … 723 724 return true; 724 725 } 725 726 726 727 if( empty( $this->attributes["mimetype"] ) ) { 727 728 return true;
