本文整理汇总了PHP中tools::upload方法的典型用法代码示例。如果您正苦于以下问题:PHP tools::upload方法的具体用法?PHP tools::upload怎么用?PHP tools::upload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tools
的用法示例。
在下文中一共展示了tools::upload方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: admin_images
function admin_images($productID)
{
if (!empty($_FILES)) {
$upload_dir = _DIR_ . '/assets/img/product/';
$upload = tools::upload($_FILES, $upload_dir);
if (!$upload) {
tools::setFlash($this->l('An error has occurred'), 'error');
tools::redirect("/admin/product/images/{$productID}");
} else {
foreach ($upload as $img) {
// generate the thumbnails
$original = $upload_dir . $img;
$thumbnails_dir = "{$upload_dir}thumb/{$productID}/";
// create the folder if not exists
if (!is_dir($thumbnails_dir)) {
mkdir($thumbnails_dir, 0777);
}
tools::thumbnail($original, $thumbnails_dir . 'home_label.jpg', $this->settings['thumbnails']['home_label']['width'], $this->settings['thumbnails']['home_label']['height']);
tools::thumbnail($original, $thumbnails_dir . 'home_list.jpg', $this->settings['thumbnails']['home_list']['width'], $this->settings['thumbnails']['home_list']['height']);
tools::thumbnail($original, $thumbnails_dir . 'product_full.jpg', $this->settings['thumbnails']['product_full']['width'], $this->settings['thumbnails']['product_full']['height']);
tools::thumbnail($original, $thumbnails_dir . 'product_gallery.jpg', $this->settings['thumbnails']['product_gallery']['width'], $this->settings['thumbnails']['product_gallery']['height']);
tools::thumbnail($original, $thumbnails_dir . 'product_thumb.jpg', $this->settings['thumbnails']['product_thumb']['width'], $this->settings['thumbnails']['product_thumb']['height']);
// add the image link to db
$toInsert = array('product_id' => $productID, 'link' => $img, 'created' => date("Y-m-d H:i:s"));
if (!$this->product->getImageByProductId($productID)) {
$toInsert['by_default'] = 1;
}
$this->product->insertImage($toInsert);
}
tools::setFlash($this->l('Request processed'), 'success');
tools::redirect('/admin/product/images/' . $productID);
}
}
$this->smarty->assign(array('images' => $this->product->getAllImages($productID), 'product' => $this->product->get($productID)));
$this->smarty->display('admin/auction/product_images.tpl');
}
示例2: admin_edit
function admin_edit($id)
{
if (!empty($_POST)) {
// image upload
if (isset($_FILES['image'])) {
$image = tools::upload($_FILES['image']);
} else {
$image = null;
}
if (!empty($image)) {
$this->exec("UPDATE " . DB_PREFIX . "testimonials SET image='" . $image . "' WHERE id=" . $id . "");
}
// data edit
$post_data = tools::filter($_POST);
$sql_request = $this->exec("UPDATE " . DB_PREFIX . "testimonials SET text='" . $post_data['text'] . "', \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t active='" . $post_data['active'] . "' \r\n\t\t\t\t\t\t\t\t\t\tWHERE id=" . $id . "");
if ($sql_request) {
tools::setFlash($this->l('Request processed'), 'success');
tools::redirect('/admin/testimonial');
}
}
$testimonial = $this->exec_one("SELECT * FROM " . DB_PREFIX . "testimonials WHERE id=" . $id . "");
$this->smarty->assign('testimonial', $testimonial);
$this->smarty->display('admin/content/edit_testimonial.tpl');
}