function upload_file()
 {
     if (!isset($this->file) || is_null($this->file['tmp_name']) || $this->file['name'] == '') {
         //Check File //Chequea sl archivo
         //$this->file['name']=$defecto;// = "Archivo no fue subido";
         $this->ErrorMsg = "Archivo no fue subido";
         return false;
     }
     if ($this->file['size'] > $this->maxsize) {
         //Check Size
         $this->ErrorMsg = "El Archivo Excede el Tamaño permitido de {$this->maxsize} bytes";
         return false;
     }
     if (count($this->allowtypes) > 0 && !in_array($this->file['type'], $this->allowtypes) || count($this->deniedtypes) > 0 && in_array($this->file['type'], $this->deniedtypes)) {
         //Check Type //Chequea el tipo de archivo
         $this->ErrorMsg = "Tipo de Archivo '." . file_extension($this->file['name']) . " -- {$this->file['type']}' No Permitido.";
         return false;
     }
     if (!$this->newfile) {
         $this->newfile = substr(basename($this->file['name']), 0, strrpos($this->file['name'], '.'));
     }
     //No new name specified, default to old name
     $uploaddirtemp = upload_dir($this->uploaddir);
     //Create Upload Dir
     move_uploaded_file($this->file['tmp_name'], $uploaddirtemp . $this->newfile . "." . file_extension($this->file['name']));
     //Move Uploaded File
     if ($maxwidth == "" && ($maxheight = "")) {
         //No need to resize the image, user did not specify to reszie
         $this->final = "." . $this->uploaddir . $this->newfile . "." . file_extension($this->file['name']);
         return true;
     }
     //User is going to resize the image
     resize_image("." . $this->uploaddir . $this->newfile . "." . file_extension($this->file['name']), $this->maxwidth, $this->maxheight, $this->scale, $this->relscale, $this->jpegquality);
     $this->final = "." . $this->uploaddir . $this->newfile . "." . file_extension($this->file['name']);
     return true;
     //Hooray!
 }
Example #2
0
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="<?php 
echo get_home_url();
?>
">
                    <?php 
if (isset($logo->post_content)) {
    ?>
                        <img src="<?php 
    echo upload_dir() . $logo->post_content;
    ?>
" alt="">
                    <?php 
} else {
    ?>
                        <img src="<?php 
    echo get_stylesheet_uri('img');
    ?>
logo.png" alt="">
                    <?php 
}
?>
                </a>
            </div>
Example #3
0
 /**
  *   取商品图片
  *   @param int id 商品ID
  *   @param var type 类型
  */
 public function pic($id, $type = 'big')
 {
     $default = base_url() . 'images/default_' . $type . '.jpg';
     if ($id) {
         $this->load->helper('file');
         $dir = upload_dir($id);
         $filePath = '';
         if ($type == 'big') {
             $filePath = upload_folder('product') . '/' . $dir . '/cover.png';
         } else {
             if ($type == 'small') {
                 $filePath = upload_folder('product') . '/' . $dir . '/cover_thumb.png';
             }
         }
         if (file_exists($filePath)) {
             return base_url() . $filePath . '?' . rand();
         }
     }
     return $default;
 }
$slide_images = $post->get_post_by('pert_slide');
?>
                                            <ul>
                                                <?php 
if ($slide_images != NULL) {
    foreach ($slide_images as $img) {
        ?>
                                                    <li>
                                                        <a href="#" data-id="<?php 
        echo $img->id;
        ?>
">
                                                            <span class="media_edit post_edit"> <i class="fa fa-edit"></i></span>
                                                            <span class="media_trash"> <i class="fa fa-times"></i></span>
                                                            <img src="<?php 
        echo upload_dir() . $img->post_content;
        ?>
" alt="">
                                                        </a>
                                                        <?php 
        $data = seperate_slide_item($img->comment);
        ?>
                                                        <div class="slide_modal">
                                                            <h3 class="modal_title"> Slide Settings </h3>
                                                            <!-- /.modal_title -->
                                                            <div class="modal_body">
                                                                <form action="">
                                                                    <p>
                                                                        <label for="slideTitle"> Slide Title</label>
                                                                        <input type="text" class="form-control" value="<?php 
        echo isset($data['slide_title']) ? $data['slide_title'] : '';
<?php

/**
 * Home top slider
 */
$post = new posts();
$top_slide = $post->get_post_by_status('slide', 'top');
?>
<div id="home-slide" class="owl-carousel owl-theme">
<?php 
if ($top_slide != NULL) {
    foreach ($top_slide as $slide) {
        ?>
        <div class="item"><img src="<?php 
        echo upload_dir() . $slide->post_content;
        ?>
" alt="The Last of us"></div>
        <?php 
    }
} else {
    ?>
    <div class="item"><img src="<?php 
    echo get_stylesheet_uri('img');
    ?>
slid_1.png" alt="Empty Slide"></div>
    <?php 
}
?>
</div>
 * Logo Upload
 * */
if (isset($_FILES['footer_logo'])) {
    $temp = explode(".", $_FILES['footer_logo']['name']);
    $newfilename = 'site_footer_logo' . '.' . end($temp);
    $data['post_content'] = $newfilename;
    $data['post_type'] = 'footer_logo';
    $data['post_status'] = 'footer';
    $hasLogo = $post->get_single_post_by('footer_logo');
    if ($hasLogo != NULL) {
        unlink(UPLOAD_DIR . $hasLogo->post_content);
        $post->delete_post($hasLogo->id);
    }
    if (move_uploaded_file($_FILES['footer_logo']['tmp_name'], UPLOAD_DIR . $newfilename)) {
        if ($post->insert_posts($data)) {
            $id[] = $main_db->insert_id;
        }
    }
    $allImg = $post->get_multi_results_by_ID($id);
    $return = '';
    $id = NULL;
    if ($allImg != NULL) {
        foreach ($allImg as $img) {
            $src = upload_dir() . $img->post_content;
            $return .= '<li> <a href="#" data-id="' . $img->id . '"> <span class="media_trash"> <i class="fa fa-times"></i></span><img src="' . $src . '" alt=""> </a></li>';
        }
        echo $return;
    } else {
        echo $main_db->last_query;
    }
}