本文整理汇总了PHP中UploadFile::get_upload_path方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadFile::get_upload_path方法的具体用法?PHP UploadFile::get_upload_path怎么用?PHP UploadFile::get_upload_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UploadFile
的用法示例。
在下文中一共展示了UploadFile::get_upload_path方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFont
/**
* This method prepares the received data and call the addFont method of the fontManager
* @return boolean true on success
*/
private function addFont()
{
$this->log = "";
$error = false;
$files = array("pdf_metric_file", "pdf_font_file");
foreach ($files as $k) {
// handle uploaded file
$uploadFile = new UploadFile($k);
if (isset($_FILES[$k]) && $uploadFile->confirm_upload()) {
$uploadFile->final_move(basename($_FILES[$k]['name']));
$uploadFileNames[$k] = $uploadFile->get_upload_path(basename($_FILES[$k]['name']));
} else {
$this->log = translate('ERR_PDF_NO_UPLOAD', "Configurator");
$error = true;
}
}
if (!$error) {
require_once 'include/Sugarpdf/FontManager.php';
$fontManager = new FontManager();
$error = $fontManager->addFont($uploadFileNames["pdf_font_file"], $uploadFileNames["pdf_metric_file"], $_REQUEST['pdf_embedded'], $_REQUEST['pdf_encoding_table'], array(), htmlspecialchars_decode($_REQUEST['pdf_cidinfo'], ENT_QUOTES), $_REQUEST['pdf_style_list']);
$this->log .= $fontManager->log;
if ($error) {
$this->log .= implode("\n", $fontManager->errors);
}
}
return $error;
}
示例2: display
/**
* @see SugarView::display()
*/
public function display()
{
global $mod_strings, $app_strings, $current_user, $sugar_config, $app_list_strings, $locale;
$this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
$has_header = isset($_REQUEST['has_header']) ? 1 : 0;
$sugar_config['import_max_records_per_file'] = empty($sugar_config['import_max_records_per_file']) ? 1000 : $sugar_config['import_max_records_per_file'];
// Clear out this user's last import
$seedUsersLastImport = new UsersLastImport();
$seedUsersLastImport->mark_deleted_by_user_id($current_user->id);
ImportCacheFiles::clearCacheFiles();
// attempt to lookup a preexisting field map
// use the custom one if specfied to do so in step 1
$field_map = array();
$default_values = array();
$ignored_fields = array();
if (!empty($_REQUEST['source_id'])) {
$mapping_file = new ImportMap();
$mapping_file->retrieve($_REQUEST['source_id'], false);
$_REQUEST['source'] = $mapping_file->source;
$has_header = $mapping_file->has_header;
if (isset($mapping_file->delimiter)) {
$_REQUEST['custom_delimiter'] = $mapping_file->delimiter;
}
if (isset($mapping_file->enclosure)) {
$_REQUEST['custom_enclosure'] = htmlentities($mapping_file->enclosure);
}
$field_map = $mapping_file->getMapping();
$default_values = $mapping_file->getDefaultValues();
$this->ss->assign("MAPNAME", $mapping_file->name);
$this->ss->assign("CHECKMAP", 'checked="checked" value="on"');
} else {
// Try to see if we have a custom mapping we can use
// based upon the where the records are coming from
// and what module we are importing into
$classname = 'ImportMap' . ucfirst($_REQUEST['source']);
if (file_exists("modules/Import/{$classname}.php")) {
require_once "modules/Import/{$classname}.php";
} elseif (file_exists("custom/modules/Import/{$classname}.php")) {
require_once "custom/modules/Import/{$classname}.php";
} else {
require_once "custom/modules/Import/ImportMapOther.php";
$classname = 'ImportMapOther';
$_REQUEST['source'] = 'other';
}
if (class_exists($classname)) {
$mapping_file = new $classname();
if (isset($mapping_file->delimiter)) {
$_REQUEST['custom_delimiter'] = $mapping_file->delimiter;
}
if (isset($mapping_file->enclosure)) {
$_REQUEST['custom_enclosure'] = htmlentities($mapping_file->enclosure);
}
$ignored_fields = $mapping_file->getIgnoredFields($_REQUEST['import_module']);
$field_map = $mapping_file->getMapping($_REQUEST['import_module']);
}
}
$this->ss->assign("CUSTOM_DELIMITER", !empty($_REQUEST['custom_delimiter']) ? $_REQUEST['custom_delimiter'] : ",");
$this->ss->assign("CUSTOM_ENCLOSURE", !empty($_REQUEST['custom_enclosure']) ? $_REQUEST['custom_enclosure'] : "");
// handle uploaded file
$uploadFile = new UploadFile('userfile');
if (isset($_FILES['userfile']) && $uploadFile->confirm_upload()) {
$uploadFile->final_move('IMPORT_' . $this->bean->object_name . '_' . $current_user->id);
$uploadFileName = $uploadFile->get_upload_path('IMPORT_' . $this->bean->object_name . '_' . $current_user->id);
} else {
$this->_showImportError($mod_strings['LBL_IMPORT_MODULE_ERROR_NO_UPLOAD'], $_REQUEST['import_module'], 'Step2');
return;
}
// split file into parts
$splitter = new ImportFileSplitter($uploadFileName, $sugar_config['import_max_records_per_file']);
$splitter->splitSourceFile($_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES), $has_header);
// Now parse the file and look for errors
$importFile = new ImportFile($uploadFileName, $_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES));
if (!$importFile->fileExists()) {
$this->_showImportError($mod_strings['LBL_CANNOT_OPEN'], $_REQUEST['import_module'], 'Step2');
return;
}
// retrieve first 3 rows
$rows = array();
$system_charset = $locale->default_export_charset;
$user_charset = $locale->getExportCharset();
$other_charsets = 'UTF-8, UTF-7, ASCII, CP1252, EUC-JP, SJIS, eucJP-win, SJIS-win, JIS, ISO-2022-JP';
$detectable_charsets = "UTF-8, {$user_charset}, {$system_charset}, {$other_charsets}";
// Bug 26824 - mb_detect_encoding() thinks CP1252 is IS0-8859-1, so use that instead in the encoding list passed to the function
$detectable_charsets = str_replace('CP1252', 'ISO-8859-1', $detectable_charsets);
$charset_for_import = $user_charset;
//We will set the default import charset option by user's preference.
$able_to_detect = function_exists('mb_detect_encoding');
for ($i = 0; $i < 3; $i++) {
$rows[$i] = $importFile->getNextRow();
if (!empty($rows[$i]) && $able_to_detect) {
foreach ($rows[$i] as &$temp_value) {
$current_charset = mb_detect_encoding($temp_value, $detectable_charsets);
if (!empty($current_charset) && $current_charset != "UTF-8") {
$temp_value = $locale->translateCharset($temp_value, $current_charset);
// we will use utf-8 for displaying the data on the page.
$charset_for_import = $current_charset;
//set the default import charset option according to the current_charset.
//.........这里部分代码省略.........
示例3: display
/**
* @see SugarView::display()
*/
public function display()
{
global $mod_strings, $app_strings, $current_user;
global $sugar_config, $locale;
$this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
$this->ss->assign("TYPE", !empty($_REQUEST['type']) ? $_REQUEST['type'] : "import");
$this->ss->assign("SOURCE_ID", $_REQUEST['source_id']);
$this->instruction = 'LBL_SELECT_PROPERTY_INSTRUCTION';
$this->ss->assign('INSTRUCTION', $this->getInstruction());
$this->ss->assign("MODULE_TITLE", $this->getModuleTitle(false), ENT_NOQUOTES);
$this->ss->assign("CURRENT_STEP", $this->currentStep);
$sugar_config['import_max_records_per_file'] = empty($sugar_config['import_max_records_per_file']) ? 1000 : $sugar_config['import_max_records_per_file'];
$importSource = isset($_REQUEST['source']) ? $_REQUEST['source'] : 'csv';
// Clear out this user's last import
$seedUsersLastImport = BeanFactory::getBean('Import_2');
$seedUsersLastImport->mark_deleted_by_user_id($current_user->id);
ImportCacheFiles::clearCacheFiles();
// handle uploaded file
$uploadFile = new UploadFile('userfile');
if (isset($_FILES['userfile']) && $uploadFile->confirm_upload()) {
$uploadFile->final_move('IMPORT_' . $this->bean->object_name . '_' . $current_user->id);
$uploadFileName = $uploadFile->get_upload_path('IMPORT_' . $this->bean->object_name . '_' . $current_user->id);
} elseif (!empty($_REQUEST['tmp_file'])) {
$uploadFileName = "upload://" . basename($_REQUEST['tmp_file']);
} else {
$this->_showImportError($mod_strings['LBL_IMPORT_MODULE_ERROR_NO_UPLOAD'], $_REQUEST['import_module'], 'Step2', true, null, true);
return;
}
//check the file size, we dont want to process an empty file
if (isset($_FILES['userfile']['size']) && $_FILES['userfile']['size'] == 0) {
//this file is empty, throw error message
$this->_showImportError($mod_strings['LBL_NO_LINES'], $_REQUEST['import_module'], 'Step2', false, null, true);
return;
}
$mimeTypeOk = true;
//check to see if the file mime type is not a form of text or application octed streramand fire error if not
if (isset($_FILES['userfile']['type']) && strpos($_FILES['userfile']['type'], 'octet-stream') === false && strpos($_FILES['userfile']['type'], 'text') === false && strpos($_FILES['userfile']['type'], 'application/vnd.ms-excel') === false) {
//this file does not have a known text or application type of mime type, issue the warning
$error_msgs[] = $mod_strings['LBL_MIME_TYPE_ERROR_1'];
$error_msgs[] = $mod_strings['LBL_MIME_TYPE_ERROR_2'];
$this->_showImportError($error_msgs, $_REQUEST['import_module'], 'Step2', true, $mod_strings['LBL_OK']);
$mimeTypeOk = false;
}
$this->ss->assign("FILE_NAME", $uploadFileName);
// Now parse the file and look for errors
$importFile = new ImportFile($uploadFileName, $_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES), FALSE);
if ($this->shouldAutoDetectProperties($importSource)) {
$GLOBALS['log']->debug("Auto detecing csv properties...");
$autoDetectOk = $importFile->autoDetectCSVProperties();
$importFileMap = array();
$this->ss->assign("SOURCE", 'csv');
if ($autoDetectOk === FALSE) {
//show error only if previous mime type check has passed
if ($mimeTypeOk) {
$this->ss->assign("AUTO_DETECT_ERROR", $mod_strings['LBL_AUTO_DETECT_ERROR']);
}
} else {
$dateFormat = $importFile->getDateFormat();
$timeFormat = $importFile->getTimeFormat();
if ($dateFormat) {
$importFileMap['importlocale_dateformat'] = $dateFormat;
}
if ($timeFormat) {
$importFileMap['importlocale_timeformat'] = $timeFormat;
}
}
} else {
$impotMapSeed = $this->getImportMap($importSource);
$importFile->setImportFileMap($impotMapSeed);
$importFileMap = $impotMapSeed->getMapping($_REQUEST['import_module']);
}
$delimeter = $importFile->getFieldDelimeter();
$enclosure = $importFile->getFieldEnclosure();
$hasHeader = $importFile->hasHeaderRow();
$encodeOutput = TRUE;
//Handle users navigating back through the wizard.
if (!empty($_REQUEST['previous_action']) && $_REQUEST['previous_action'] == 'Confirm') {
$encodeOutput = FALSE;
$importFileMap = $this->overloadImportFileMapFromRequest($importFileMap);
$delimeter = !empty($_REQUEST['custom_delimiter']) ? $_REQUEST['custom_delimiter'] : $delimeter;
$enclosure = isset($_REQUEST['custom_enclosure']) ? $_REQUEST['custom_enclosure'] : $enclosure;
$enclosure = html_entity_decode($enclosure, ENT_QUOTES);
$hasHeader = !empty($_REQUEST['has_header']) ? $_REQUEST['has_header'] : $hasHeader;
if ($hasHeader == 'on') {
$hasHeader = true;
} else {
if ($hasHeader == 'off') {
$hasHeader = false;
}
}
}
$this->ss->assign("IMPORT_ENCLOSURE_OPTIONS", $this->getEnclosureOptions($enclosure));
$this->ss->assign("IMPORT_DELIMETER_OPTIONS", $this->getDelimeterOptions($delimeter));
$this->ss->assign("CUSTOM_DELIMITER", $delimeter);
$this->ss->assign("CUSTOM_ENCLOSURE", htmlentities($enclosure, ENT_QUOTES, 'utf-8'));
$hasHeaderFlag = $hasHeader ? " CHECKED" : "";
$this->ss->assign("HAS_HEADER_CHECKED", $hasHeaderFlag);
//.........这里部分代码省略.........
示例4: array
mkdir_recursive($cachedir);
}
// cn: bug 11012 - fixed some MIME types not getting picked up. Also changed array iterator.
$imgType = array('image/gif', 'image/png', 'image/x-png', 'image/bmp', 'image/jpeg', 'image/jpg', 'image/pjpeg');
$ret = array();
foreach ($_FILES as $k => $file) {
if (in_array(strtolower($_FILES[$k]['type']), $imgType) && $_FILES[$k]['size'] > 0) {
$upload_file = new UploadFile($k);
// check the file
if ($upload_file->confirm_upload()) {
$dest = $cachedir . basename($upload_file->get_stored_file_name());
// target name
$guid = create_guid();
if ($upload_file->final_move($guid)) {
// move to uploads
$path = $upload_file->get_upload_path($guid);
// if file is OK, copy to cache
if (verify_uploaded_image($path) && copy($path, $dest)) {
$ret[] = $dest;
}
// remove temp file
unlink($path);
}
}
}
}
if (!empty($ret)) {
$json = getJSONobj();
echo $json->encode($ret);
//return the parameters
}