6 * @author Bryan Tong Minh
8 * Implements regular file uploads
10 class UploadFromFile
extends UploadBase
{
11 protected $mWebUpload = null;
13 function initializeFromRequest( &$request ) {
14 $this->mWebUpload
= $request->getUpload( 'wpUploadFile' );
16 $desiredDestName = $request->getText( 'wpDestFile' );
17 if( !$desiredDestName )
18 $desiredDestName = $this->mWebUpload
->getName();
19 return $this->initializePathInfo(
21 $this->mWebUpload
->getTempName(),
22 $this->mWebUpload
->getSize()
26 * Entry point for upload from file.
28 function initialize( $name, $tempPath, $fileSize ) {
29 return $this->initializePathInfo( $name, $tempPath, $fileSize );
31 static function isValidRequest( $request ) {
32 # Allow all requests, even if no file is present, so that an error
33 # because a post_max_size or upload_max_filesize overflow
37 public function verifyUpload() {
38 # Check for a post_max_size or upload_max_size overflow, so that a
39 # proper error can be shown to the user
40 if ( is_null( $this->mTempPath
) ||
$this->isEmptyFile() ) {
41 if ( $this->mWebUpload
->isIniSizeOverflow() ) {
42 global $wgMaxUploadSize;
44 'status' => self
::FILE_TOO_LARGE
,
47 wfShorthandToInteger( ini_get( 'upload_max_filesize' ) ),
48 wfShorthandToInteger( ini_get( 'post_max_size' ) )
54 return parent
::verifyUpload();