本文整理汇总了PHP中FileUpload::Setup方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUpload::Setup方法的具体用法?PHP FileUpload::Setup怎么用?PHP FileUpload::Setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUpload
的用法示例。
在下文中一共展示了FileUpload::Setup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: FileUpload
$intMaxFileSize = $CMS->SYS->GetSysPref(C_PREF_AVATAR_MAX_SIZE);
$strFileSizeMB = $intMaxFileSize / 1000000 . "MB";
$strFileSizeKB = $intMaxFileSize / 1000 . "KB";
$strFileError = "";
if ($_POST) {
$blnSubmitForm = true;
// ** FILE UPLOAD CHECKING ** //
// Process file errors
if ($_FILES['txtFile']['error'] && $_FILES['txtFile']['name']) {
$blnSubmitForm = false;
$strFileSubmitError = $CMS->FL->SubmissionError($_FILES['txtFile']['error']);
$strFileError = $CMS->AC->InvalidFormData($strFileSubmitError);
}
$FU = new FileUpload();
if ($_FILES['txtFile']['name']) {
$FU->Setup($_FILES['txtFile']['name'], "Avatar", "");
} else {
$blnSubmitForm = false;
$strFileError = $CMS->AC->InvalidFormData("");
}
// Check file size
if ($_FILES['txtFile']['size'] > $intMaxFileSize) {
$blnSubmitForm = false;
$strFileError = $CMS->Err_MWarn(M_ERR_UPLOAD_FILESIZE, $FU->GetDBFilePath());
}
// Prevent two uploads referencing the same file
if ($_FILES['txtFile']['name']) {
if ($CMS->FL->IsDuplicateFile($FU->GetDBFilePath(), "")) {
$blnSubmitForm = false;
$strFileError = $CMS->Err_MWarn(M_ERR_UPLOAD_DUPLICATE, $FU->GetDBFilePath());
}
示例2: FileUpload
//$strFileError = $CMS->AC->InvalidFormData(M_ERR_UPLOAD_OR_URL);
} else {
$blnHasAttachment = true;
}
}
if ($blnHasAttachment) {
// Process file errors
if ($_FILES['txtFile']['error'] && $_FILES['txtFile']['name']) {
$blnSubmitForm = false;
$strFileSubmitError = $CMS->FL->SubmissionError($_FILES['txtFile']['error']);
$strFileError = $CMS->AC->InvalidFormData($strFileSubmitError);
}
// OK to upload?
$FU = new FileUpload();
if ($_FILES['txtFile']['name']) {
$FU->Setup($_FILES['txtFile']['name'], "File", "Upload");
} elseif ($_POST['txtFileLocation']) {
$FU->Setup($_POST['txtFileLocation'], "File", "Link");
}
// Prevent two uploads referencing the same file
if ($_FILES['txtFile']['name']) {
$strCurrentFileID = $blnExistingAttachment ? $intFileID : "";
if ($CMS->FL->IsDuplicateFile($FU->GetDBFilePath(), $strCurrentFileID)) {
$blnSubmitForm = false;
$strFileError = $CMS->Err_MWarn(M_ERR_UPLOAD_DUPLICATE, $FU->GetDBFilePath());
} else {
// Is this a valid file?
$fileExtension = $CMS->GetExtensionFromPath($FU->GetDBFilePath());
$fileExtension = strtoupper($fileExtension);
$allowedTypesArray = explode(",", C_ALLOWED_FILE_TYPES);
if (!in_array($fileExtension, $allowedTypesArray)) {