本文整理匯總了PHP中wpl_global::upload方法的典型用法代碼示例。如果您正苦於以下問題:PHP wpl_global::upload方法的具體用法?PHP wpl_global::upload怎麽用?PHP wpl_global::upload使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wpl_global
的用法示例。
在下文中一共展示了wpl_global::upload方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: install_package
private function install_package()
{
/** upload file into tmp directory **/
$file = wpl_request::getVar('wpl_addon_file', '', 'FILES');
$tmp_directory = wpl_global::init_tmp_folder();
$dest = $tmp_directory . 'package.zip';
$response = wpl_global::upload($file, $dest, array('zip'), 20971520);
#20MB
if (trim($response['error']) != '') {
$this->response($response);
}
$zip_file = $dest;
wpl_global::zip_extract($zip_file, $tmp_directory);
$script_file = $tmp_directory . 'installer.php';
if (!wpl_file::exists($script_file)) {
$this->response(array('error' => __("Installer file doesn't exist!", WPL_TEXTDOMAIN), 'message' => ''));
}
/** including installer and run the install method **/
include $script_file;
if (!class_exists('wpl_installer')) {
$this->response(array('error' => __("Installer class doesn't exist!", WPL_TEXTDOMAIN), 'message' => ''));
}
/** run install script **/
$wpl_installer = new wpl_installer();
$wpl_installer->path = $tmp_directory;
if (!$wpl_installer->run()) {
$this->response(array('error' => $wpl_installer->error, 'message' => ''));
}
/** Trigger Event **/
wpl_global::event_handler('package_installed', array('package_id' => isset($wpl_installer->addon_id) ? $wpl_installer->addon_id : 0));
$message = $wpl_installer->message ? $wpl_installer->message : __('Package installed.', WPL_TEXTDOMAIN);
$this->response(array('error' => '', 'message' => $message));
}
示例2: import_settings
private function import_settings()
{
$file = wpl_request::getVar('wpl_import_file', '', 'FILES');
$tmp_directory = wpl_global::init_tmp_folder();
$ext = strtolower(wpl_file::getExt($file['name']));
$settings_file = $tmp_directory . 'settings.' . $ext;
$response = wpl_global::upload($file, $settings_file, array('json', 'xml'), 20971520);
#20MB
if (trim($response['error']) != '') {
echo json_encode($response);
exit;
}
if (wpl_settings::import_settings($settings_file)) {
$error = '';
$message = __('Settings have been imported successfuly!', WPL_TEXTDOMAIN);
} else {
$error = '1';
$message = __('Cannot import settings!', WPL_TEXTDOMAIN);
}
echo json_encode(array('error' => $error, 'message' => $message));
exit;
}