更新到PHP 7.3.11版后表单上载错误
在我们的主机将PHP版本更新为7.3.11之前,我有一个正常工作的表单。现在,当您尝试提交到表单时,它会显示以下错误消息: 致命错误:未捕获ArgumentCounter错误:参数太少,无法 函数sl_upload(),传入了2个 /nfs/c07/h03/mnt/113634/domains/myurl.com/html/appLms/modules/question/class.upload.php 在第331行和第3行 /nfs/c07/h03/mnt/113634/domains/myurl.com/html/lib/lib.upload.php:74 堆栈跟踪:#0 /nfs/c07/h03/mnt/113634/domains/myurl.com/html/appLms/modules/question/class.upload.php(331): sl_上传('/var/tmp/phpU0P…','/appLms/test/2_…')#1 /nfs/c07/h03/mnt/113634/domains/myurl.com/html/appLms/lib/lib.test.php(1106): 上传问题->存储答案(对象(跟踪测试),数组“1”)#2 /nfs/c07/h03/mnt/113634/domains/myurl.com/html/appLms/modules/test/do.test.php(1208): PlayTestManagement->storePage('1','1')#3 /nfs/c07/h03/mnt/113634/domains/myurl.com/html/appLms/modules/test/do.test.php(592): 展示结果(对象(学习测试),29)#4 /nfs/c07/h03/mnt/113634/domains/myurl.com/html/appLms/class.module/learning.test.php(309): 在/nfs/c07/h03/mnt/113634/domains/myurl.com/html/lib/lib.upload.php中 第74行 我没有改变任何密码。唯一改变的是PHP版本。因此,我甚至不知道如何开始修复这个问题 下面是class.upload.php>第331行的内容更新到PHP 7.3.11版后表单上载错误,php,runtime-error,updates,Php,Runtime Error,Updates,在我们的主机将PHP版本更新为7.3.11之前,我有一个正常工作的表单。现在,当您尝试提交到表单时,它会显示以下错误消息: 致命错误:未捕获ArgumentCounter错误:参数太少,无法 函数sl_upload(),传入了2个 /nfs/c07/h03/mnt/113634/domains/myurl.com/html/appLms/modules/question/class.upload.php 在第331行和第3行 /nfs/c07/h03/mnt/113634/domains/myu
sl_open_fileoperations();
if(!sl_upload($_FILES['quest']['tmp_name'][$this->id], $path.$savefile)) {
$savefile = Lang::t('_QUEST_ERR_IN_UPLOAD');
}
sl_close_fileoperations();
} else {
$savefile = Lang::t('_QUEST_ERR_IN_UPLOAD');
}
}
…下面是lib.upload.php>第74行的内容
function sl_upload( $srcFile, $dstFile, $file_ext) {
$uploadType = Get::cfg('uploadType', null);
// check if the mime type is allowed by the whitelist
// if the whitelist is empty all types are accepted
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();
}
}
基于这一点,我不确定要改变什么,我不想打破以前的做法
网站的所有其他部分都正常工作,包括登录等PHP功能。提前感谢您提供的任何提示。尝试更换:
sl_upload($_FILES['quest']['tmp_name'][$this->id], $path.$savefile)
与:
说明:sl_upload
函数需要3个参数,而您只传递了2个
因为它以前对您很有效(尽管它一定触发了警告,除非您的错误报告非常松散,否则可能会记录在某个地方),所以将null
作为第三个参数传递应该会产生与以前相同的结果
但是,最好弄清楚函数参数应该用于什么,因为它标记为必需(没有默认值)。这是否回答了您的问题。特别是,你好,杰托,谢谢你。不幸的是,没有,因为我的函数有预期的3个参数。没有sl_上传($_FILES['quest']['tmp_name'][$this->id],$path.$savefile)
首先,让我先说,唯一改变的是PHP版本更新了。在此之前,所有这些代码都正常工作。据我统计,这有3:1)['quest']2]['tmp_name']3][$this->id]。我遗漏了什么吗?$\u FILES['quest']['tmp\u name'][$this->id]
是第一个参数,$path.$savefile
是第二个参数。它以前工作的原因可能是因为PHP版本<7.1在发生这种情况时只生成警告,但从那时起它被更改为致命错误。请参阅我第一条评论中的第二个链接。谢谢@Jeto。这在短期内解决了问题,我将继续研究您的建议。
sl_upload($_FILES['quest']['tmp_name'][$this->id], $path.$savefile, null);