3 * Implements regular file uploads
7 * @author Bryan Tong Minh
10 class UploadFromFile
extends UploadBase
{
11 protected $mUpload = null;
13 function initializeFromRequest( &$request ) {
14 $upload = $request->getUpload( 'wpUploadFile' );
15 $desiredDestName = $request->getText( 'wpDestFile' );
16 if( !$desiredDestName )
17 $desiredDestName = $upload->getName();
19 return $this->initialize( $desiredDestName, $upload );
23 * Initialize from a filename and a WebRequestUpload
25 function initialize( $name, $webRequestUpload ) {
26 $this->mUpload
= $webRequestUpload;
27 return $this->initializePathInfo( $name,
28 $this->mUpload
->getTempName(), $this->mUpload
->getSize() );
30 static function isValidRequest( $request ) {
31 # Allow all requests, even if no file is present, so that an error
32 # because a post_max_size or upload_max_filesize overflow
36 public function verifyUpload() {
37 # Check for a post_max_size or upload_max_size overflow, so that a
38 # proper error can be shown to the user
39 if ( is_null( $this->mTempPath
) ||
$this->isEmptyFile() ) {
40 if ( $this->mUpload
->isIniSizeOverflow() ) {
41 global $wgMaxUploadSize;
43 'status' => self
::FILE_TOO_LARGE
,
46 wfShorthandToInteger( ini_get( 'upload_max_filesize' ) ),
47 wfShorthandToInteger( ini_get( 'post_max_size' ) )
53 return parent
::verifyUpload();