Too few arguments in Uploader

Install and configure FormaLMS and DoceboCE
Post Reply
3mike
Newbie
Posts: 1
Joined: Thu May 07, 2020 2:36 am

Too few arguments in Uploader

Post by 3mike »

Hi! I tried searching but didn't see this:

I'm receiving the follow error when I attempt to upload a course object or file:
Fatal error: Uncaught ArgumentCountError: Too few arguments to function sl_upload(), 2 passed in /home1/atlastm/public_html/appLms/modules/htmlpage/htmlpage.php on line 233 and exactly 3 expected in /home1/atlastm/public_html/lib/lib.upload.php:74 Stack trace: #0 /home1/atlastm/public_html/appLms/modules/htmlpage/htmlpage.php(233): sl_upload('/tmp/phpWOIzKA', '/appLms/htmlpag...') #1 /home1/atlastm/public_html/appLms/modules/htmlpage/htmlpage.php(86): save_file(Array) #2 /home1/atlastm/public_html/appLms/modules/htmlpage/htmlpage.php(247): inspage() #3 /home1/atlastm/public_html/appLms/class.module/class.definition.php(105): include('/home1/atlastm/...') #4 /home1/atlastm/public_html/appLms/index.php(84): LmsModule->loadBody() #5 {main} thrown in /home1/atlastm/public_html/lib/lib.upload.php on line 74]

This is the fuction from htmlpage.php on line 233:

Code: Select all

function save_file($file) {
	require_once(_base_.'/lib/lib.upload.php');

	$path = '/appLms/htmlpages/';

	if($file['name'] != '') {

		$savefile = $_SESSION['idCourse'].'_'.rand(0,100).'_'.time().'_'.$file['name'];
		if(!file_exists($GLOBALS['where_files_relative'].$path.$savefile)) {

			sl_open_fileoperations();
			if(!sl_upload($file['tmp_name'], $path.$savefile)) {

				$savefile = '';
			}
			sl_close_fileoperations();
			return $savefile;
		}
	}
and here is the fuction from lib.upload.php on line 74

Code: Select all

`function sl_upload( $srcFile, $dstFile, $file_ext) {
	$uploadType = Get::cfg('uploadType', null);

	
	require_once(_lib_.'/lib.mimetype.php');
	$upload_whitelist =Get::sett('file_upload_whitelist', 'rar,exe,zip,jpg,gif,png,txt,csv,rtf,xml,doc,docx,xls,xlsx,ppt,pptx,odt,ods,odp,pdf,xps,mp4,mp3,flv,swf,mov,wav,ogg,flac,wma,wmv,jpeg');
	$upload_whitelist_arr =explode(',', trim($upload_whitelist, ','));
	if (!empty($upload_whitelist_arr)) {
		$valid_ext = false;
		$ext=strtolower(substr(strrchr($dstFile, "."), 1));
		if($ext!=""){
			$file_ext =strtolower(substr(strrchr($dstFile, "."), 1));
		}

		foreach ($upload_whitelist_arr as $k=>$v) { // remove extra spaces and set lower case
			$ext =trim(strtolower($v));
			$mt =mimetype($ext);
			if ($mt) { $mimetype_arr[]=$mt; }
			getOtherMime($ext, $mimetype_arr);
			if ($ext == $file_ext) {
				$valid_ext =true;
			}
		}
		$mimetype_arr = array_unique($mimetype_arr);
		if ( class_exists('finfo') && method_exists('finfo', 'file')) {
			$finfo =new finfo(FILEINFO_MIME_TYPE);
			$file_mime_type =$finfo->file($srcFile);
		}
		else {
			$file_mime_type =mime_content_type($srcFile);
		}
		if (!$valid_ext || !in_array($file_mime_type, $mimetype_arr)) {
			return false;
		}
	}
	$dstFile =stripslashes($dstFile);
	if( $uploadType == "ftp" ) {
		return sl_upload_ftp( $srcFile, $dstFile );
	} elseif( $uploadType == "cgi" ) {
		return sl_upload_cgi( $srcFile, $dstFile );
	} elseif( $uploadType == "fs" || $uploadType == null ) {
		return sl_upload_fs( $srcFile, $dstFile );
	} else {
        $event = new \appCore\Events\Core\FileSystem\UploadEvent($srcFile, $dstFile);
        \appCore\Events\DispatcherManager::dispatch(\appCore\Events\Core\FileSystem\UploadEvent::EVENT_NAME, $event);
		unlink($srcFile);
        return $event->getResult();
    }
}
Apologies if I've given more, or less, info than needed. Thanks in advance!

User avatar
alberto
FormaLms Guru
Posts: 990
Joined: Fri Mar 02, 2012 9:18 am
Contact:

Re: Too few arguments in Uploader

Post by alberto »

Hi, welcom on board!

It seems a PHP version issue. Forma 2.x support PHP up to version 7.0
If you using a higher version please downgrade to 7.0
--------------------------------------------------
Become a CONTRIBUTOR

Support the project for FREE!
www.Elearnit.net

alfa24
Senior Boarder
Posts: 1006
Joined: Fri Nov 24, 2017 8:45 am
Version: forma.lms 1.4.2

Re: Too few arguments in Uploader

Post by alfa24 »

Search the forum before asking, please:
https://forum.formalms.org/7/13277.html?p=20636#p20636
I'm Jasmines, the One. If you need, you can contact me.

Post Reply