Exemple #1
0
function file_upload($articleid)
{
	global $wfsConfig;
	global $wfsUploadSize;

	if ($articleid == 0) return 21;

	$error = check_post_files('filename');
	if ($error != 0) return $error;

	$upload = new uploadfile('filename');
	$upload->loadPostVars();
	$upload->setMaxFilesize($wfsUploadSize);
	$upload->setMode($wfsConfig['wfsmode']);
	$distfilename = $upload->doUploadToRandumFile(XOOPS_ROOT_PATH."/".$wfsConfig['filesbasepath']);

	if (!$distfilename) return $upload->getErrorCode();

	$file = new WfsFiles();
	$file->setByUploadFile($upload);
	$file->setFiledescript($_POST['filedescript']);
//	$file->setFiletext($_POST['filetext']);
	$file->setgroupid($_POST['groupid']);

	if (empty($_POST['fileshowname'])) 
	{	$file->setFileShowName($upload->getOriginalName());	} 
	else 
	{   $file->setFileShowName($_POST['fileshowname']);	}

	$file->setArticleid($articleid);
	$ret = $file->store();

	if (!$ret)	return 22;

	return 0;
}