本文整理汇总了PHP中UploadFile::upload_doc方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadFile::upload_doc方法的具体用法?PHP UploadFile::upload_doc怎么用?PHP UploadFile::upload_doc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UploadFile
的用法示例。
在下文中一共展示了UploadFile::upload_doc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save(&$bean, $params, $field, $vardef, $prefix = '')
{
$fakeDisplayParams = array();
$this->fillInOptions($vardef, $fakeDisplayParams);
require_once 'include/upload_file.php';
$upload_file = new UploadFile($prefix . $field . '_file');
//remove file
if (isset($_REQUEST['remove_file_' . $field]) && $params['remove_file_' . $field] == 1) {
$upload_file->unlink_file($bean->{$field});
$bean->{$field} = "";
}
$move = false;
if (isset($_FILES[$prefix . $field . '_file']) && $upload_file->confirm_upload()) {
$bean->{$field} = $upload_file->get_stored_file_name();
$bean->file_mime_type = $upload_file->mime_type;
$bean->file_ext = $upload_file->file_ext;
$move = true;
}
if (!empty($params['isDuplicate']) && $params['isDuplicate'] == 'true') {
// This way of detecting duplicates is used in Notes
$old_id = $params['relate_id'];
}
if (!empty($params['duplicateSave']) && !empty($params['duplicateId'])) {
// It's a duplicate
$old_id = $params['duplicateId'];
}
// Backwards compatibility for fields that still use customCode to handle the file uploads
if (!$move && empty($old_id) && isset($_FILES['uploadfile'])) {
$upload_file = new UploadFile('uploadfile');
if ($upload_file->confirm_upload()) {
$bean->{$field} = $upload_file->get_stored_file_name();
$bean->file_mime_type = $upload_file->mime_type;
$bean->file_ext = $upload_file->file_ext;
$move = true;
}
} else {
if (!$move && !empty($old_id) && isset($_REQUEST['uploadfile']) && !isset($_REQUEST[$prefix . $field . '_file'])) {
// I think we are duplicating a backwards compatibility module.
$upload_file = new UploadFile('uploadfile');
}
}
if (empty($bean->id)) {
$bean->id = create_guid();
$bean->new_with_id = true;
}
if ($move) {
$upload_file->final_move($bean->id);
$upload_file->upload_doc($bean, $bean->id, $params[$prefix . $vardef['docType']], $bean->{$field}, $upload_file->mime_type);
} else {
if (!empty($old_id)) {
// It's a duplicate, I think
if (empty($params[$prefix . $vardef['docUrl']])) {
$upload_file->duplicate_file($old_id, $bean->id, $bean->{$field});
} else {
$docType = $vardef['docType'];
$bean->{$docType} = $params[$prefix . $field . '_old_doctype'];
}
} else {
if (!empty($params[$prefix . $field . '_remoteName'])) {
// We aren't moving, we might need to do some remote linking
$displayParams = array();
$this->fillInOptions($vardef, $displayParams);
if (isset($params[$prefix . $vardef['docId']]) && !empty($params[$prefix . $vardef['docId']]) && isset($params[$prefix . $vardef['docType']]) && !empty($params[$prefix . $vardef['docType']])) {
$bean->{$field} = $params[$prefix . $field . '_remoteName'];
require_once 'include/utils/file_utils.php';
$extension = get_file_extension($bean->{$field});
if (!empty($extension)) {
$bean->file_ext = $extension;
$bean->file_mime_type = get_mime_content_type_from_filename($bean->{$field});
}
}
}
}
}
if ($vardef['allowEapm'] == true && empty($bean->{$field})) {
$GLOBALS['log']->info("The {$field} is empty, clearing out the lot");
// Looks like we are emptying this out
$clearFields = array('docId', 'docType', 'docUrl', 'docDirectUrl');
foreach ($clearFields as $clearMe) {
if (!isset($vardef[$clearMe])) {
continue;
}
$clearField = $vardef[$clearMe];
$bean->{$clearField} = '';
}
}
}
示例2: save
public function save($bean, $params, $field, $vardef, $prefix = '')
{
$fakeDisplayParams = array();
$this->fillInOptions($vardef, $fakeDisplayParams);
require_once 'include/upload_file.php';
$upload_file = new UploadFile($prefix . $field . '_file');
//remove file
if (isset($_REQUEST['remove_file_' . $field]) && $params['remove_file_' . $field] == 1) {
$upload_file->unlink_file($bean->{$field});
$bean->{$field} = "";
}
$move = false;
// In case of failure midway, we need to reset the values of the bean
$originalvals = array('value' => $bean->{$field});
// Bug 57400 - Some beans with a filename field type do NOT have file_mime_type
// or file_ext. In the case of Documents, for example, this happens to be
// the case, since the DocumentRevisions bean is where these fields are found.
if (isset($bean->file_mime_type)) {
$originalvals['mime'] = $bean->file_mime_type;
}
if (isset($bean->file_ext)) {
$originalvals['ext'] = $bean->file_ext;
}
if (isset($_FILES[$prefix . $field . '_file']) && $upload_file->confirm_upload()) {
// in order to avoid any discrepancies of MIME type with the download code,
// call the same MIME function instead of using the uploaded file's mime type property.
$mimeType = get_file_mime_type($upload_file->get_temp_file_location(), 'application/octet-stream');
//verify the image
if (in_array($mimeType, self::$imageFileMimeTypes) && !verify_image_file($upload_file->get_temp_file_location())) {
$this->error = string_format($GLOBALS['app_strings']['LBL_UPLOAD_IMAGE_FILE_NOT_SUPPORTED'], array($upload_file->file_ext));
return;
}
$bean->{$field} = $upload_file->get_stored_file_name();
$bean->file_mime_type = $upload_file->mime_type;
$bean->file_ext = $upload_file->file_ext;
$move = true;
} else {
$this->error = $upload_file->getErrorMessage();
}
if (!empty($params['isDuplicate']) && $params['isDuplicate'] == 'true') {
// This way of detecting duplicates is used in Notes
$old_id = $params['relate_id'];
}
if (!empty($params['duplicateSave']) && !empty($params['duplicateId'])) {
// It's a duplicate
$old_id = $params['duplicateId'];
}
// case when we should copy one file to another using merge-duplicate view
// $params[$field . '_duplicateBeanId'] contains id of bean from
// which we should copy file.
if (!empty($params[$field . '_duplicateBeanId'])) {
$duplicateModuleId = $params[$field . '_duplicateBeanId'];
}
// Backwards compatibility for fields that still use customCode to handle the file uploads
if (!$move && empty($old_id) && isset($_FILES['uploadfile'])) {
$upload_file = new UploadFile('uploadfile');
if ($upload_file->confirm_upload()) {
$bean->{$field} = $upload_file->get_stored_file_name();
$bean->file_mime_type = $upload_file->mime_type;
$bean->file_ext = $upload_file->file_ext;
$move = true;
} else {
$this->error = $upload_file->getErrorMessage();
}
} elseif (!$move && !empty($old_id) && isset($_REQUEST['uploadfile']) && !isset($_REQUEST[$prefix . $field . '_file'])) {
// I think we are duplicating a backwards compatibility module.
$upload_file = new UploadFile('uploadfile');
}
if (empty($bean->id)) {
$bean->id = create_guid();
$bean->new_with_id = true;
}
if ($move) {
$temp = !empty($params['temp']);
// Added checking of final move to capture errors that might occur
if ($upload_file->final_move($bean->id, $temp)) {
if (!$temp) {
// This fixes an undefined index warning being thrown
$docType = isset($vardef['docType']) && isset($params[$prefix . $vardef['docType']]) ? $params[$prefix . $vardef['docType']] : null;
$upload_file->upload_doc($bean, $bean->id, $docType, $bean->{$field}, $upload_file->mime_type);
}
} else {
// Reset the bean back to original, but only if we had set them.
$bean->{$field} = $originalvals['value'];
// See comments for these properties above in regards to Bug 57400
if (isset($originalvals['mime'])) {
$bean->file_mime_type = $originalvals['mime'];
}
if (isset($originalvals['ext'])) {
$bean->file_ext = $originalvals['ext'];
}
// Report the error
$this->error = $upload_file->getErrorMessage();
}
} elseif (!empty($old_id)) {
// It's a duplicate, I think
if (empty($vardef['docUrl']) || empty($params[$prefix . $vardef['docUrl']])) {
$upload_file->duplicate_file($old_id, $bean->id, $bean->{$field});
} else {
$docType = $vardef['docType'];
//.........这里部分代码省略.........