/** * Returns the filename for a temporary file * * @param string $type string to prepend to the filename, typically to indicate the file's use * @return string filename */ private static function _createFileName($type = self::FILE_MISCELLANEOUS) { global $current_user; $importdir = self::getImportDir(); // ensure dir exists and writable UploadStream::ensureDir($importdir, true); return "{$importdir}/{$type}_{$current_user->id}.csv"; }
global $sugar_config; $supportedExtensions = array('jpg', 'png', 'jpeg'); $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
$supportedExtensions = array('jpg', 'png', 'jpeg'); $json = getJSONobj(); $rmdir = true; $returnArray = array(); if ($json->decode(html_entity_decode($_REQUEST['forQuotes']))) { $returnArray['forQuotes'] = "quotes"; } else { $returnArray['forQuotes'] = "company"; } $upload_ok = false; $upload_path = 'tmp_logo_' . $returnArray['forQuotes'] . '_upload'; if (isset($_FILES['file_1'])) { $upload = new UploadFile('file_1'); if ($upload->confirm_upload()) { $upload_dir = 'upload://' . $upload_path; UploadStream::ensureDir($upload_dir); $file_name = $upload_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(true); } if (file_exists($file_name) && is_file($file_name)) { $encoded_file_name = rawurlencode($upload->get_stored_file_name()); $returnArray['path'] = $upload_path . '/' . $encoded_file_name; $returnArray['url'] = 'cache/images/' . $encoded_file_name;