本文整理汇总了PHP中UploadFile::final_move方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadFile::final_move方法的具体用法?PHP UploadFile::final_move怎么用?PHP UploadFile::final_move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UploadFile
的用法示例。
在下文中一共展示了UploadFile::final_move方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: UploadFile
function action_save()
{
require_once 'include/upload_file.php';
$GLOBALS['log']->debug('PERFORMING NOTES SAVE');
$upload_file = new UploadFile('uploadfile');
$do_final_move = 0;
if (isset($_FILES['uploadfile']) && $upload_file->confirm_upload()) {
if (!empty($this->bean->id) && !empty($_REQUEST['old_filename'])) {
$upload_file->unlink_file($this->bean->id, $_REQUEST['old_filename']);
}
$this->bean->filename = $upload_file->get_stored_file_name();
$this->bean->file_mime_type = $upload_file->mime_type;
$do_final_move = 1;
} else {
if (isset($_REQUEST['old_filename'])) {
$this->bean->filename = $_REQUEST['old_filename'];
}
}
$this->bean->save();
if ($do_final_move) {
$upload_file->final_move($this->bean->id);
} else {
if (!empty($_REQUEST['old_id'])) {
$upload_file->duplicate_file($_REQUEST['old_id'], $this->bean->id, $this->bean->filename);
}
}
}
示例3: UploadFile
function action_save()
{
require_once 'include/upload_file.php';
$GLOBALS['log']->debug('PERFORMING NOTES SAVE');
$upload_file = new UploadFile('uploadfile');
$do_final_move = 0;
if (isset($_FILES['uploadfile']) && $upload_file->confirm_upload()) {
if (!empty($this->bean->id) && !empty($_REQUEST['old_filename'])) {
$upload_file->unlink_file($this->bean->id, $_REQUEST['old_filename']);
}
$this->bean->filename = $upload_file->get_stored_file_name();
$this->bean->file_mime_type = $upload_file->mime_type;
$do_final_move = 1;
} else {
if (isset($_REQUEST['old_filename'])) {
$this->bean->filename = $_REQUEST['old_filename'];
}
}
$check_notify = false;
if (!empty($_POST['assigned_user_id']) && (empty($this->bean->fetched_row) || $this->bean->fetched_row['assigned_user_id'] != $_POST['assigned_user_id']) && $_POST['assigned_user_id'] != $GLOBALS['current_user']->id) {
$check_notify = true;
}
$this->bean->save($check_notify);
if ($do_final_move) {
$upload_file->final_move($this->bean->id);
} else {
if (!empty($_REQUEST['old_id'])) {
$upload_file->duplicate_file($_REQUEST['old_id'], $this->bean->id, $this->bean->filename);
}
}
}
示例4: save
function save($check_notify = false)
{
$move = false;
$upload_file = new UploadFile('uploadfile');
if (isset($_FILES['uploadfile']) && $upload_file->confirm_upload()) {
$this->filename = $upload_file->get_stored_file_name();
$this->file_mime_type = $upload_file->mime_type;
$this->file_ext = $upload_file->file_ext;
$move = true;
}
parent::save($check_notify);
if ($move) {
$upload_file->final_move($this->id);
}
return $this->id;
//handleRedirect($return_id, $this->object_name);
}
示例5: File
function action_save()
{
$move = false;
$file = new File();
$file = populateFromPost('', $file);
$upload_file = new UploadFile('uploadfile');
$return_id = '';
if (isset($_FILES['uploadfile']) && $upload_file->confirm_upload()) {
$file->filename = $upload_file->get_stored_file_name();
$file->file_mime_type = $upload_file->mime_type;
$file->file_ext = $upload_file->file_ext;
$move = true;
}
$return_id = $file->save();
if ($move) {
$upload_file->final_move($file->id);
}
handleRedirect($return_id, $this->object_name);
}
示例6: UploadFile
function action_save()
{
require_once 'include/upload_file.php';
// CCL - Bugs 41103 and 43751. 41103 address the issue where the parent_id is set, but
// the relate_id field overrides the relationship. 43751 fixes the problem where the relate_id and
// parent_id are the same value (in which case it should just use relate_id) by adding the != check
if (!empty($_REQUEST['relate_id']) && !empty($_REQUEST['parent_id']) && $_REQUEST['relate_id'] != $_REQUEST['parent_id']) {
$_REQUEST['relate_id'] = false;
}
$GLOBALS['log']->debug('PERFORMING NOTES SAVE');
$upload_file = new UploadFile('uploadfile');
$do_final_move = 0;
if (isset($_FILES['uploadfile']) && $upload_file->confirm_upload()) {
if (!empty($this->bean->id) && !empty($_REQUEST['old_filename'])) {
$upload_file->unlink_file($this->bean->id, $_REQUEST['old_filename']);
}
$this->bean->filename = $upload_file->get_stored_file_name();
$this->bean->file_mime_type = $upload_file->mime_type;
$do_final_move = 1;
} else {
if (isset($_REQUEST['old_filename'])) {
$this->bean->filename = $_REQUEST['old_filename'];
}
}
$check_notify = false;
if (!empty($_POST['assigned_user_id']) && (empty($this->bean->fetched_row) || $this->bean->fetched_row['assigned_user_id'] != $_POST['assigned_user_id']) && $_POST['assigned_user_id'] != $GLOBALS['current_user']->id) {
$check_notify = true;
}
$this->bean->save($check_notify);
if ($do_final_move) {
$upload_file->final_move($this->bean->id);
} else {
if (!empty($_REQUEST['old_id'])) {
$upload_file->duplicate_file($_REQUEST['old_id'], $this->bean->id, $this->bean->filename);
}
}
}
示例7: save
public function save(&$bean, $params, $field, $properties, $prefix = '')
{
require_once 'include/upload_file.php';
$upload_file = new UploadFile($prefix . $field);
//remove file
if (isset($_REQUEST['remove_file_' . $field]) && $_REQUEST['remove_file_' . $field] == 1) {
$upload_file->unlink_file($bean->{$field});
$bean->{$field} = "";
}
$move = false;
if (isset($_FILES[$prefix . $field]) && $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 ($move) {
if (empty($bean->id)) {
$bean->id = create_guid();
$bean->new_with_id = true;
}
$upload_file->final_move($bean->id);
}
}
示例8: logThis
upload no matter what, set the default to 60M */
global $sugar_config;
$upload_maxsize_backup = $sugar_config['upload_maxsize'];
$sugar_config['upload_maxsize'] = 60000000;
/* End Bug 51722 */
if (!$upload->confirm_upload()) {
logThis('ERROR: no file uploaded!');
echo $mod_strings['ERR_UW_NO_FILE_UPLOADED'];
$error = $upload->get_upload_error();
// add PHP error if isset
if ($error) {
$out = "<b><span class='error'>{$mod_strings['ERR_UW_PHP_FILE_ERRORS'][$error]}</span></b><br />";
}
} else {
$tempFile = "upload://" . $upload->get_stored_file_name();
if (!$upload->final_move($tempFile)) {
logThis('ERROR: could not move temporary file to final destination!');
unlinkUWTempFiles();
$out = "<b><span class='error'>{$mod_strings['ERR_UW_NOT_VALID_UPLOAD']}</span></b><br />";
} else {
logThis('File uploaded to ' . $tempFile);
$base_filename = urldecode(basename($tempFile));
$perform = true;
}
}
/* Bug 51722 - Restore the upload size in the config */
$sugar_config['upload_maxsize'] = $upload_maxsize_backup;
/* End Bug 51722 */
}
if ($perform) {
$manifest_file = extractManifest($tempFile);
示例9: PackageManager
$perform = false;
$tempFile = '';
if (isset($_REQUEST['release_id']) && $_REQUEST['release_id'] != "") {
require_once 'ModuleInstall/PackageManager/PackageManager.php';
$pm = new PackageManager();
$tempFile = $pm->download($_REQUEST['release_id']);
$perform = true;
//$base_filename = urldecode($tempFile);
} else {
$file = new UploadFile('language_pack');
if ($file->confirm_upload()) {
$perform = true;
if (strpos($file->mime_type, 'zip') !== false) {
// only .zip files
$tempFile = $file->get_stored_filename();
if ($file->final_move($tempFile)) {
$perform = true;
} else {
$errors[] = $mod_strings['ERR_LANG_UPLOAD_3'];
}
} else {
$errors[] = $mod_strings['ERR_LANG_UPLOAD_2'];
}
}
}
if ($perform) {
// check for a real file
$uploadResult = $mod_strings['LBL_LANG_SUCCESS'];
$result = langPackUnpack('langpack', $tempFile);
} else {
$errors[] = $mod_strings['ERR_LANG_UPLOAD_1'];
示例10: PackageManager
require_once 'ModuleInstall/PackageManager.php';
$pm = new PackageManager();
$tempFile = $pm->download('', '', $_REQUEST['release_id']);
$perform = true;
$base_filename = urldecode($tempFile);
} elseif (!empty($_REQUEST['load_module_from_dir'])) {
//copy file to proper location then call performSetup
copy($_REQUEST['load_module_from_dir'] . '/' . $_REQUEST['upgrade_zip_escaped'], "upload://" . $_REQUEST['upgrade_zip_escaped']);
$perform = true;
$base_filename = urldecode($_REQUEST['upgrade_zip_escaped']);
} else {
if (empty($_FILES['upgrade_zip']['tmp_name'])) {
echo $mod_strings['ERR_UW_NO_UPLOAD_FILE'];
} else {
$upload = new UploadFile('upgrade_zip');
if (!$upload->confirm_upload() || strtolower(pathinfo($upload->get_stored_file_name(), PATHINFO_EXTENSION)) != 'zip' || !$upload->final_move($upload->get_stored_file_name())) {
unlinkTempFiles();
sugar_die("Invalid Package");
} else {
$tempFile = "upload://" . $upload->get_stored_file_name();
$perform = true;
$base_filename = urldecode($_REQUEST['upgrade_zip_escaped']);
}
}
}
if ($perform) {
$manifest_file = extractManifest($tempFile);
if (is_file($manifest_file)) {
//SCAN THE MANIFEST FILE TO MAKE SURE NO COPIES OR ANYTHING ARE HAPPENING IN IT
$ms = new ModuleScanner();
$fileIssues = $ms->scanFile($manifest_file);
示例11: 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.
//.........这里部分代码省略.........
示例12: array
require_once 'include/upload_file.php';
if (!is_dir($cachedir = sugar_cached('images/'))) {
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);
示例13: UploadFile
function preprocess_fields_on_save()
{
parent::preprocess_fields_on_save();
require_once 'include/upload_file.php';
$upload_file = new UploadFile("picture");
//remove file
if (isset($_REQUEST['remove_imagefile_picture']) && $_REQUEST['remove_imagefile_picture'] == 1) {
UploadFile::unlink_file($this->picture);
$this->picture = "";
}
//uploadfile
if (isset($_FILES['picture'])) {
//confirm only image file type can be uploaded
$imgType = array('image/gif', 'image/png', 'image/bmp', 'image/jpeg', 'image/jpg', 'image/pjpeg');
if (in_array($_FILES['picture']["type"], $imgType)) {
if ($upload_file->confirm_upload()) {
$this->picture = create_guid();
$upload_file->final_move($this->picture);
}
}
}
}
示例14: getJSONobj
$json = getJSONobj();
$rmdir = true;
$returnArray = array();
if ($json->decode(html_entity_decode($_REQUEST['forQuotes']))) {
$returnArray['forQuotes'] = "quotes";
} else {
$returnArray['forQuotes'] = "company";
}
$upload_ok = false;
if (isset($_FILES['file_1'])) {
$upload = new UploadFile('file_1');
if ($upload->confirm_upload()) {
$dir = "upload://cache/images";
UploadStream::ensureDir($dir);
$file_name = $dir . "/" . $upload->get_stored_file_name();
if ($upload->final_move($file_name)) {
$upload_ok = true;
}
}
}
if (!$upload_ok) {
$returnArray['data'] = 'not_recognize';
echo $json->encode($returnArray);
sugar_cleanup();
exit;
}
if (file_exists($file_name) && is_file($file_name)) {
$returnArray['path'] = substr($file_name, 9);
// strip upload prefix
$returnArray['url'] = 'cache/images/' . $upload->get_stored_file_name();
if (!verify_uploaded_image($file_name, $returnArray['forQuotes'] == 'quotes')) {
示例15: populateFromPost
if (isset($_REQUEST['SaveRevision'])) {
//fetch the document record.
$Document->retrieve($_REQUEST['return_id']);
if ($useRequired && !checkRequired($prefix, array_keys($Revision->required_fields))) {
return null;
}
$Revision = populateFromPost($prefix, $Revision);
$upload_file = new UploadFile('uploadfile');
if (isset($_FILES['uploadfile']) && $upload_file->confirm_upload()) {
$Revision->filename = $upload_file->get_stored_file_name();
$Revision->file_mime_type = $upload_file->mime_type;
$Revision->file_ext = $upload_file->file_ext;
$do_final_move = 1;
}
//save revision
$Revision->document_id = $_REQUEST['return_id'];
$Revision->save();
//revsion is the document.
$Document->document_revision_id = $Revision->id;
$Document->save();
$return_id = $Document->id;
}
if ($do_final_move) {
$upload_file->final_move($Revision->id);
} else {
if (!empty($_REQUEST['old_id'])) {
$upload_file->duplicate_file($_REQUEST['old_id'], $Revision->id, $Revision->filename);
}
}
$GLOBALS['log']->debug("Saved record with id of " . $return_id);
handleRedirect($return_id, "Documents");