本文整理汇总了PHP中convertBytes函数的典型用法代码示例。如果您正苦于以下问题:PHP convertBytes函数的具体用法?PHP convertBytes怎么用?PHP convertBytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了convertBytes函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '', $lkid = '')
{
// Must set the type of the class
$this->type = 'image';
// Get the max upload size from PHP
$this->maxFileSize = ini_get('upload_max_filesize');
$this->maxFileSizeBytes = convertBytes($this->maxFileSize);
// Must call the parent class
parent::__construct($db, $user, $mediaid, $layoutid, $regionid, $lkid);
}
示例2: cleanString
$post['file_original'] = cleanString($embed['title']);
$post['file'] = str_ireplace(array('src="https://', 'src="http://'), 'src="//', $embed['html']);
} else {
if (isset($_FILES['file'])) {
if ($_FILES['file']['name'] != "") {
validateFileUpload();
if (!is_file($_FILES['file']['tmp_name']) || !is_readable($_FILES['file']['tmp_name'])) {
fancyDie("File transfer failure. Please retry the submission.");
}
if (TINYIB_MAXKB > 0 && filesize($_FILES['file']['tmp_name']) > TINYIB_MAXKB * 1024) {
fancyDie("That file is larger than " . TINYIB_MAXKBDESC . ".");
}
$post['file_original'] = trim(htmlentities(substr($_FILES['file']['name'], 0, 50), ENT_QUOTES));
$post['file_hex'] = md5_file($_FILES['file']['tmp_name']);
$post['file_size'] = $_FILES['file']['size'];
$post['file_size_formatted'] = convertBytes($post['file_size']);
// Uploaded file type
$file_type = strtolower(preg_replace('/.*(\\..+)/', '\\1', $_FILES['file']['name']));
if ($file_type == '.jpeg') {
$file_type = '.jpg';
}
if ($file_type == '.weba') {
$file_type = '.webm';
}
// Thumbnail type
if ($file_type == '.webm') {
$thumb_type = '.jpg';
} else {
if ($file_type == '.swf') {
$thumb_type = '.png';
} else {
示例3: convertBytes
<option value='Nein' <?php
if ("REX_VALUE[15]" == 'nein') {
echo 'selected';
}
?>
>Nein</option>
<option value='Ja' <?php
if ("REX_VALUE[15]" == 'Ja') {
echo 'selected';
}
?>
>Ja</option>
</select>
<div class="col-md-12">
<?php
echo 'Uploadgröße, max: ' . convertBytes(ini_get('upload_max_filesize')) / 1048576 . 'MB';
?>
</div>
</div>
<?php
}
?>
示例4: convertBytes
} else {
$uploadPercent = ($uploadNow - $uploadLast) / $uploadLast * 100;
}
if ($uploadPercent < $config['syncDiff']) {
$errors[] = '<span class="text-danger">Debit upload : chute de ' . -round($uploadPercent, 2) . '% (' . convertBytes($uploadLast) . ' -> ' . convertBytes($uploadNow) . ')</span>';
}
/* Download */
if (!$downloadNow) {
$downloadPercent = 100;
} elseif (!$downloadLast) {
$downloadPercent = 0;
} else {
$downloadPercent = ($downloadNow - $downloadLast) / $downloadLast * 100;
}
if ($downloadPercent < $config['syncDiff']) {
$errors[] = '<span class="text-danger">Debit download : chute de ' . -round($downloadPercent, 2) . '% (' . convertBytes($downloadLast) . ' -> ' . convertBytes($downloadNow) . ')</span>';
}
if ($errors) {
$errorsTest->execute();
if (!$errorsTest->rowCount()) {
$errorsJSON = json_encode($errors);
$errorsSave->execute();
}
} else {
$errorsDelete->execute();
}
}
/* Envoi du mail */
if ($reinit) {
$config['startNotify'] = strtotime($config['startNotify']);
$config['stopNotify'] = strtotime($config['stopNotify']);
示例5: min
// Memory allocated for handling script
$temp_ini_upload_mb = min($temp_ini_max_upload, $temp_ini_max_post, $temp_ini_memory_limit);
function convertBytes($value)
{
if (is_numeric($value)) {
return $value . ' MB';
} else {
$value_length = strlen($value);
$qty = substr($value, 0, $value_length - 1);
$unit = strtolower(substr($value, $value_length - 1));
switch ($unit) {
case 'k':
$qty *= 1024;
break;
case 'm':
$qty *= 1048576;
break;
case 'g':
$qty *= 1073741824;
break;
}
return $qty;
}
}
$ini_max_upload = convertBytes($temp_ini_max_upload);
$ini_max_post = convertBytes($temp_ini_max_post);
$ini_max_memory_limit = convertBytes($temp_ini_memory_limit);
$ini_max_upload_mb = convertBytes($temp_ini_upload_mb);
$ini_max_input_vars = (int) ini_get('max_input_vars');
$ini_max_file_uploads = (int) ini_get('max_file_uploads');
$_SESSION['kcfinder'] = '1';
示例6: set_checkbox
echo set_checkbox('inputCanDownload', '1', $details->userCanDownload == '1' ? true : false);
?>
/>
</div>
</div>
<div class="control-group hidden useUser">
<label class="control-label" for="inputMaxSize"><?php
echo __('user_lbl_maxsize');
?>
</label>
<div class="controls">
<input type="text" id="inputMaxSize" name="inputMaxSize" value="<?php
echo set_value('inputMaxSize', $details->userMaxFileSize);
?>
" class="span1" /> in Bytes ( <strong>php.ini:</strong> <?php
echo roundsize(convertBytes(ini_get('upload_max_filesize')));
?>
)
</div>
</div>
<div class="control-group hidden useUser">
<label class="control-label" for="inputMaxFiles"><?php
echo __('user_lbl_maxfiles');
?>
</label>
<div class="controls">
<input type="text" id="inputMaxFiles" name="inputMaxFiles" value="<?php
echo set_value('inputMaxFiles', $details->userMaxNumFiles);
?>
" class="span1" />
</div>
示例7: convertBytes
$qty *= 1024;
break;
case 'm':
$qty *= 1048576;
break;
case 'g':
$qty *= 1073741824;
break;
}
return $qty;
}
}
// Create a few variables to shorten lines below
$u_m_f = convertBytes(ini_get('upload_max_filesize'));
$p_m_s = convertBytes(ini_get('post_max_size'));
$m_l = convertBytes(ini_get('memory_limit'));
// Grab the data and display it depending on which checkboxes are selected
if ($chk_anon == 'Yes') {
echo '<strong>[b]Anonymous User[/b]</strong><br />';
$sql = 'SELECT username, username_clean
FROM ' . USERS_TABLE . '
WHERE user_id = "1"';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
if ($row['username_clean'] != 'anonymous') {
echo 'Database user_id 1 is: ' . $row['username'] . ' || username_clean: ' . $row['username_clean'] . '<br />';
}
}
$db->sql_freeresult($result);
if (defined('ANONYMOUS')) {
echo 'Constant user_id: ' . ANONYMOUS . '<br />';
示例8: ImportCsvForm
public function ImportCsvForm()
{
global $session;
$db =& $this->db;
$response = new ResponseManager();
$dataSetId = Kit::GetParam('datasetid', _GET, _INT);
$dataSet = Kit::GetParam('dataset', _GET, _STRING);
$auth = $this->user->DataSetAuth($dataSetId, true);
if (!$auth->edit) {
trigger_error(__('Access Denied'), E_USER_ERROR);
}
// Set the Session / Security information
$sessionId = session_id();
$securityToken = CreateFormToken();
$session->setSecurityToken($securityToken);
// Find the max file size
$maxFileSizeBytes = convertBytes(ini_get('upload_max_filesize'));
// Set some information about the form
Theme::Set('form_id', 'DataSetImportCsvForm');
Theme::Set('form_action', 'index.php?p=dataset&q=ImportCsv');
Theme::Set('form_meta', '<input type="hidden" name="dataset" value="' . $dataSet . '" /><input type="hidden" name="datasetid" value="' . $dataSetId . '" /><input type="hidden" id="txtFileName" name="txtFileName" readonly="true" /><input type="hidden" name="hidFileID" id="hidFileID" value="" />');
Theme::Set('form_upload_id', 'file_upload');
Theme::Set('form_upload_action', 'index.php?p=content&q=FileUpload');
Theme::Set('form_upload_meta', '<input type="hidden" id="PHPSESSID" value="' . $sessionId . '" /><input type="hidden" id="SecurityToken" value="' . $securityToken . '" /><input type="hidden" name="MAX_FILE_SIZE" value="' . $maxFileSizeBytes . '" />');
// Enumerate over the columns in the DataSet and offer a column mapping for each one (from the file)
$SQL = "";
$SQL .= "SELECT DataSetColumnID, Heading ";
$SQL .= " FROM datasetcolumn ";
$SQL .= sprintf(" WHERE DataSetID = %d ", $dataSetId);
$SQL .= " AND DataSetColumnTypeID = 1 ";
$SQL .= "ORDER BY ColumnOrder ";
// Load results into an array
$dataSetColumns = $db->GetArray($SQL);
if (!is_array($dataSetColumns)) {
trigger_error($db->error());
trigger_error(__('Error getting list of dataSetColumns'), E_USER_ERROR);
}
$rows = array();
$i = 0;
foreach ($dataSetColumns as $row) {
$i++;
$row['heading'] = Kit::ValidateParam($row['Heading'], _STRING);
$row['formfieldid'] = 'csvImport_' . Kit::ValidateParam($row['DataSetColumnID'], _INT);
$row['auto_column_number'] = $i;
$rows[] = $row;
}
Theme::Set('fields', $rows);
$form = Theme::RenderReturn('dataset_form_csv_import');
$response->SetFormRequestResponse($form, __('CSV Import'), '350px', '200px');
$response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DataSet', 'ImportCsv') . '")');
$response->AddButton(__('Cancel'), 'XiboDialogClose()');
$response->AddButton(__('Import'), '$("#DataSetImportCsvForm").submit()');
$response->Respond();
}
示例9: ImportForm
public function ImportForm()
{
global $session;
$db =& $this->db;
$response = new ResponseManager();
// Set the Session / Security information
$sessionId = session_id();
$securityToken = CreateFormToken();
$session->setSecurityToken($securityToken);
// Find the max file size
$maxFileSizeBytes = convertBytes(ini_get('upload_max_filesize'));
// Set some information about the form
Theme::Set('form_id', 'LayoutImportForm');
Theme::Set('form_action', 'index.php?p=layout&q=Import');
Theme::Set('form_meta', '<input type="hidden" id="txtFileName" name="txtFileName" readonly="true" /><input type="hidden" name="hidFileID" id="hidFileID" value="" /><input type="hidden" name="template" value="' . Kit::GetParam('template', _GET, _STRING, 'false') . '" />');
Theme::Set('form_upload_id', 'file_upload');
Theme::Set('form_upload_action', 'index.php?p=content&q=FileUpload');
Theme::Set('form_upload_meta', '<input type="hidden" id="PHPSESSID" value="' . $sessionId . '" /><input type="hidden" id="SecurityToken" value="' . $securityToken . '" /><input type="hidden" name="MAX_FILE_SIZE" value="' . $maxFileSizeBytes . '" />');
Theme::Set('prepend', Theme::RenderReturn('form_file_upload_single'));
$formFields = array();
$formFields[] = FormManager::AddText('layout', __('Name'), NULL, __('The Name of the Layout - (1 - 50 characters). Leave blank to use the name from the import.'), 'n');
$formFields[] = FormManager::AddCheckbox('replaceExisting', __('Replace Existing Media?'), NULL, __('If the import finds existing media with the same name, should it be replaced in the Layout or should the Layout use that media.'), 'r');
if (Kit::GetParam('template', _GET, _STRING, 'false') != 'true') {
$formFields[] = FormManager::AddCheckbox('importTags', __('Import Tags?'), NULL, __('Would you like to import any tags contained on the layout.'), 't');
}
Theme::Set('form_fields', $formFields);
$response->SetFormRequestResponse(NULL, __('Import Layout'), '350px', '200px');
$response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DataSet', 'ImportCsv') . '")');
$response->AddButton(__('Cancel'), 'XiboDialogClose()');
$response->AddButton(__('Import'), '$("#LayoutImportForm").submit()');
$response->Respond();
}
示例10: base_url
echo base_url();
?>
assets/styles/jquery.fileupload-ui.css">
<!-- Shim to make HTML5 elements usable in older Internet Explorer versions -->
<!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<div class="container">
<div class="page-header">
<h3><?php
echo __('up_head_fileupload');
?>
</h3>
</div>
<blockquote>
<p><?php
echo __('up_desc_fileupload', array(roundsize(convertBytes(ini_get('upload_max_filesize')))));
?>
</p>
</blockquote>
<br>
<form id="fileupload" action="<?php
echo site_url('admin/uploads/upload');
?>
" method="POST" enctype="multipart/form-data">
<div class="row fileupload-buttonbar">
<div class="span7">
<span class="dsbl btn fileinput-button">
<i class="icon-plus"></i>
<span><?php
echo __('up_btn_selectfile');
?>
示例11: function
$displayBackend = function () {
/*
* If exists do not display
* Debugbar on Backend UI
*
*/
if (class_exists('Debugbar')) {
Debugbar::disable();
}
/*
* Server's based configuration
* to send as parameters to UI
*
*/
$env = App::environment();
$config = ['baseUrl' => Config::get('subbly.backendUri', '/admin') . '/', 'domain' => URL::to('/') . '/', 'apiUrl' => URL::to('/api/v1') . '/', 'env' => $env, 'debug' => (bool) Config::get('app.debug'), 'locales' => Config::get('backend::locales.list'), 'i18nresource' => URL::to(Config::get('backend::locales.resources')), 'currencies' => Config::get('backend::currencies'), 'orderStatus' => Config::get('backend::order'), 'siteStatus' => Config::get('backend::site.status'), 'upload' => ['maxFileSize' => convertBytes(ini_get('upload_max_filesize'))]];
return View::make('backend::backend', ['environment' => $env, 'config' => $config]);
};
Route::get('/', $displayBackend);
Route::get('{url}', $displayBackend)->where('url', '.*');
});
/*
* Return empty response.
* Allow natural autocomplete on ajax form
*/
Route::any('/void', function () {
$response = Response::make(array(), 204);
$response->header('Content-Type', 'json');
return $response;
});
/*
示例12: safe_repair
safe_repair('pixie_files');
}
} else {
$message = $multi_upload->show_error_string();
}
} else {
$message = $lang['file_upload_tag_error'];
}
// If the folder is not writeable, we need to indicate that to the user
$file_upload_success = $dir . $file_name;
if (!file_exists($file_upload_success)) {
$message = $lang['upload_filemanager_fail'];
}
}
echo "<div id=\"blocks\">\r\n\t\t\t\t\t<div class=\"admin_block\" id=\"admin_block_filemanager\">\r\n\t\t\t\t\t\t<h3>" . $lang['upload'] . "</h3>\r\n\t\t\t\t\t\t<form accept-charset=\"UTF-8\" action=\"?s={$s}&x={$x}\" method=\"post\" id=\"upload_form\" enctype=\"multipart/form-data\">\r\n\t\t\t\t\t\t<fieldset>\r\n\t\t\t\t\t\t<legend>" . $lang['upload'] . "</legend>\r\n\t\t\t\t\t\t\t<div class=\"form_row\">\r\n\t\t\t\t\t\t\t\t<div class=\"form_label\"><label for=\"upload\">" . $lang['form_upload_file'] . " <span class=\"form_required\">" . $lang['form_required'] . "</span></label><span class=\"form_help\">" . $lang['form_help_upload_file'] . " " . $lang['file_manager_info'] . "</span></div>\r\n\t\t\t\t\t\t\t<div class=\"form_item_file\"><input type=\"file\" class=\"form_text\" name=\"upload[]\" id=\"upload\" size=\"18\" /></div>";
echo '<div class=\\form_label\\><span><small>' . $lang['filemanager_max_upload'] . convertBytes(ini_get('upload_max_filesize')) / 1048576 . 'MB.</small></span></div>';
echo "</div>\r\n\t\t\t\t\t\t\t<div class=\"form_row\">\r\n\t\t\t\t\t\t\t\t<div class=\"form_label\"><label for=\"file_tags\">" . $lang['tags'] . " <span class=\"form_required\">" . $lang['form_required'] . "</span></label><span class=\"form_help\">" . $lang['form_help_upload_tags'] . "</span></div>\r\n\t\t\t\t\t\t\t\t<div class=\"form_item\"><input type=\"text\" class=\"form_text\" id=\"file_tags\" name=\"file_tags\" size=\"18\" /></div>\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t<div class=\"form_row\">\r\n\t\t\t\t\t\t\t\t<div class=\"form_label\"><label for=\"replace\">" . $lang['form_upload_replace_files'] . "</label><span class=\"form_help\">" . $lang['form_help_upload_replace_files'] . "</span></div>\r\n\t\t\t\t\t\t\t\t<div class=\"form_item_check\"><input type=\"checkbox\" id=\"replace\" name=\"replace\" value=\"y\" /></div>\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t<div class=\"form_row_button\">\r\n\t\t\t\t\t\t\t\t<input type=\"submit\" class=\"form_submit\" name=\"submit_upload\" value=\"" . $lang['upload'] . "\" />\r\n\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"{$max_size}\" />";
if (isset($ck) && $ck) {
echo "<input type=\"hidden\" name=\"ckFuncNumReturn\" value=\"{$CKEditorFuncNum}\" />";
}
if (isset($ck) && $ck) {
echo "<input type=\"hidden\" name=\"ck\" value=\"1\" />";
}
if (isset($ckfile) && $ckfile) {
echo "<input type=\"hidden\" name=\"ckfile\" value=\"1\" />";
}
if (isset($ckimage) && $ckimage) {
echo "<input type=\"hidden\" name=\"ckimage\" value=\"1\" />";
}
echo "\t\t\t\t</div>\r\n\t\t\t\t\t\t</fieldset>\r\n\t\t\t\t\t\t</form>\r\n\t\t\t\t\t</div>";
$type = 'module';
示例13: htmlspecialchars
} else {
// Warnung ueber nicht erlaubte Datei ausgeben
$warning["el_" . $i] = $form_warn_css;
$warnblock["el_" . $i] = $form_warnblock_css;
$warning_set = 1;
$error_message .= '<div class="forminfo">Die Datei kann nicht hochgeladen werden. Evtl. liegt es an einem falschen Dateityp. Erlaubt ist hier nur: ' . $upload_Extensions_errormessage . '</div>';
}
if ($_FILES['FORM']['size'][$form_ID]['el_' . $i] < convertBytes($upload_MaxSice)) {
// alles ok
} else {
// Warnung ueber zu grosse Datei ausgeben
$warning["el_" . $i] = $form_warn_css;
$warnblock["el_" . $i] = $form_warnblock_css;
$warning_set = 1;
$error_message .= 'Die Datei "' . htmlspecialchars($targetFile) . '" ist zu groß!<br />';
$error_message .= 'Erlaubt sind maximal ' . convertBytes($upload_MaxSice) / 1048576 . ' MB';
}
}
// if (!$upload_keineDateivorhanden && $error_message == '')
}
// if (!empty($_FILES))
if (isset($error_message) and $error_message != '') {
$error_message = '<p>' . $error_message . '</p>';
} else {
$error_message = '';
}
$form_tmp = '';
$form_tmp .= $fehlerImFormaufbau;
$form_tmp .= $error_message;
$form_tmp .= "\n" . '<div class="' . $form_field_wrp . ' ' . $warnblock["el_" . $i] . '"><label ' . $warning["el_" . $i] . ' for="FORM[' . $form_ID . '][el_' . $i . ']" >' . $element[1] . $req . '</label>' . "\n";
$form_tmp .= '<input type="file" name="FORM[' . $form_ID . '][el_' . $i . ']" id="FORM[' . $form_ID . '][el_' . $i . ']" /></div>' . "\n";
示例14: get_max_upload
function get_max_upload()
{
return convertBytes(ini_get('upload_max_filesize'));
}