summaryrefslogtreecommitdiff
path: root/includes/upload/UploadFromFile.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/upload/UploadFromFile.php')
-rw-r--r--includes/upload/UploadFromFile.php33
1 files changed, 27 insertions, 6 deletions
diff --git a/includes/upload/UploadFromFile.php b/includes/upload/UploadFromFile.php
index e67ec191..c2ab6467 100644
--- a/includes/upload/UploadFromFile.php
+++ b/includes/upload/UploadFromFile.php
@@ -8,8 +8,15 @@
*/
class UploadFromFile extends UploadBase {
+
+ /**
+ * @var WebRequestUpload
+ */
protected $mUpload = null;
+ /**
+ * @param $request WebRequest
+ */
function initializeFromRequest( &$request ) {
$upload = $request->getUpload( 'wpUploadFile' );
$desiredDestName = $request->getText( 'wpDestFile' );
@@ -18,31 +25,47 @@ class UploadFromFile extends UploadBase {
return $this->initialize( $desiredDestName, $upload );
}
-
+
/**
* Initialize from a filename and a WebRequestUpload
+ * @param $name
+ * @param $webRequestUpload
*/
function initialize( $name, $webRequestUpload ) {
$this->mUpload = $webRequestUpload;
return $this->initializePathInfo( $name,
$this->mUpload->getTempName(), $this->mUpload->getSize() );
}
+
+ /**
+ * @param $request
+ * @return bool
+ */
static function isValidRequest( $request ) {
# Allow all requests, even if no file is present, so that an error
# because a post_max_size or upload_max_filesize overflow
return true;
}
-
+
+ /**
+ * @return string
+ */
+ public function getSourceType() {
+ return 'file';
+ }
+
+ /**
+ * @return array
+ */
public function verifyUpload() {
# Check for a post_max_size or upload_max_size overflow, so that a
# proper error can be shown to the user
if ( is_null( $this->mTempPath ) || $this->isEmptyFile() ) {
if ( $this->mUpload->isIniSizeOverflow() ) {
- global $wgMaxUploadSize;
return array(
'status' => UploadBase::FILE_TOO_LARGE,
'max' => min(
- $wgMaxUploadSize,
+ self::getMaxUploadSize( $this->getSourceType() ),
wfShorthandToInteger( ini_get( 'upload_max_filesize' ) ),
wfShorthandToInteger( ini_get( 'post_max_size' ) )
),
@@ -60,6 +83,4 @@ class UploadFromFile extends UploadBase {
public function getFileTempname() {
return $this->mUpload->getTempname();
}
-
-
}