当前位置: 首页>>代码示例>>PHP>>正文


PHP make_thumb函数代码示例

本文整理汇总了PHP中make_thumb函数的典型用法代码示例。如果您正苦于以下问题:PHP make_thumb函数的具体用法?PHP make_thumb怎么用?PHP make_thumb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了make_thumb函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save_image

function save_image($image_url, $storage_folder)
{
    $remote_image = file_get_contents($image_url);
    preg_match('@(.*?)\\.([^\\.]+)$@', basename($image_url), $matches);
    $local_image_name = urldecode($matches[1]);
    $local_image_ext = $matches[2];
    $counter = 2;
    while (file_exists("images/media_items/{$local_image_name}.{$local_image_ext}")) {
        $local_image_name = $local_image_name . "({$counter})";
        $counter++;
    }
    $fp = fopen("{$storage_folder}{$local_image_name}.{$local_image_ext}", 'c');
    $success = fwrite($fp, $remote_image);
    if (!$success) {
        return false;
    } else {
        make_thumb("images/media_items/{$local_image_name}.{$local_image_ext}", "images/media_items/thumbs/{$local_image_name}.{$local_image_ext}", 100);
        return "{$local_image_name}.{$local_image_ext}";
    }
}
开发者ID:randoogle,项目名称:mediaMix,代码行数:20,代码来源:header.php

示例2: _upload_file

 function _upload_file()
 {
     $ret_info = array();
     // 返回到客户端的信息
     $file = $_FILES['Filedata'];
     if ($file['error'] == UPLOAD_ERR_NO_FILE) {
         $this->json_error('no_upload_file');
         exit;
     }
     import('uploader.lib');
     // 导入上传类
     import('image.func');
     $uploader = new Uploader();
     $uploader->allowed_type(IMAGE_FILE_TYPE);
     // 限制文件类型
     $uploader->allowed_size(SIZE_GOODS_IMAGE);
     // 限制单个文件大小2M
     $uploader->addFile($file);
     if (!$uploader->file_info()) {
         $this->json_error($uploader->get_error());
         exit;
     }
     /* 取得剩余空间(单位:字节),false表示不限制 */
     $store_mod =& m('store');
     $settings = $store_mod->get_settings($this->store_id);
     $remain = $settings['space_limit'] > 0 ? $settings['space_limit'] * 1024 * 1024 - $this->mod_uploadedfile->get_file_size($this->store_id) : false;
     /* 判断能否上传 */
     if ($remain !== false) {
         if ($remain < $file['size']) {
             $this->json_error('space_limit_arrived');
             exit;
         }
     }
     /* 指定保存位置的根目录 */
     $uploader->root_dir(ROOT_PATH);
     $filename = $uploader->random_filename();
     /* 上传 */
     $file_path = $uploader->save($this->save_path, $filename);
     // 保存到指定目录
     if (!$file_path) {
         $this->json_error('file_save_error');
         exit;
     }
     $file_type = $this->_return_mimetype($file_path);
     /* 文件入库 */
     $data = array('store_id' => $this->store_id, 'file_type' => $file_type, 'file_size' => $file['size'], 'file_name' => $file['name'], 'file_path' => $file_path, 'belong' => $this->belong, 'item_id' => $this->item_id, 'add_time' => gmtime());
     $file_id = $this->mod_uploadedfile->add($data);
     if (!$file_id) {
         $this->json_error('file_add_error');
         exit;
     }
     if ($this->instance == 'goods_image') {
         /* 生成缩略图 */
         $thumbnail = dirname($file_path) . '/small_' . basename($file_path);
         $bignail = dirname($file_path) . '/big_' . basename($file_path);
         $middlenail = dirname($file_path) . '/middle_' . basename($file_path);
         $smallnail = dirname($file_path) . '/little_' . basename($file_path);
         make_thumb(ROOT_PATH . '/' . $file_path, ROOT_PATH . '/' . $bignail, 900, 900, THUMB_QUALITY);
         //生成900*900的缩略图
         make_thumb(ROOT_PATH . '/' . $file_path, ROOT_PATH . '/' . $middlenail, 420, 420, THUMB_QUALITY);
         //生成420*420的缩略图
         make_thumb(ROOT_PATH . '/' . $file_path, ROOT_PATH . '/' . $smallnail, 60, 60, THUMB_QUALITY);
         //生成60*60的缩略图
         make_thumb(ROOT_PATH . '/' . $file_path, ROOT_PATH . '/' . $thumbnail, THUMB_WIDTH, THUMB_HEIGHT, THUMB_QUALITY);
         //生成170*170的缩略图
         /* 更新商品相册 */
         $data = array('goods_id' => $this->item_id, 'image_url' => $file_path, 'thumbnail' => $thumbnail, 'bignail' => $bignail, 'middlenail' => $middlenail, 'smallnail' => $smallnail, 'sort_order' => 255, 'file_id' => $file_id);
         if (!$this->mod_goods_image->add($data)) {
             $this->json_error($this->mod_goods_imaged->get_error());
             return false;
         }
         $ret_info = array_merge($ret_info, array('thumbnail' => $thumbnail));
     }
     /* 返回客户端 */
     $ret_info = array_merge($ret_info, array('file_id' => $file_id, 'file_path' => $file_path, 'instance' => $this->instance));
     $this->json_result($ret_info);
 }
开发者ID:184609680,项目名称:wcy_O2O_95180,代码行数:77,代码来源:swfupload.app.php

示例3: update_posts

 function update_posts($id, $data)
 {
     $array["title"] = $data["title"];
     $array["url"] = $data["url"];
     $array["type"] = $data["type"];
     $array["raw_content"] = str_replace('class="my-math"', 'class="my-math" lang="latex"', $data["content"]);
     $array["content"] = strip_tags(trim($data["content"]));
     $array["category_id"] = $data["category_id"];
     $array["updated_on"] = $data["updated_on"];
     $insert_partial_data = $this->db->update("posts", $array, array('id' => $id));
     if (!empty($data['image']) && $data['image']['name'] != "") {
         $image = $data['image'];
         $path = FCPATH . "uploads/post/" . $id . "/";
         if (!is_dir($path)) {
             $images_files = FCPATH . 'uploads/post/' . $id;
             $this->recursiveRemoveDirectory($images_files);
         }
         $old = umask(0);
         mkdir($path, 0777, true);
         umask($old);
         $image['name'] = str_replace(" ", "-", $image['name']);
         $offset = strpos($image['name'], '.');
         $image['name_for_listing'] = substr_replace($image['name'], HEIGHT_FOR_POST_LISTING . "_" . WIDTH_FOR_POST_LISTING, $offset) . ".jpg";
         $image['name_for_detail_listing'] = substr_replace($image['name'], HEIGHT_FOR_POST_DETAILS . "_" . WIDTH_FOR_POST_DETAILS, $offset) . ".jpg";
         $upload = move_uploaded_file($image['tmp_name'], $path . $image['name']);
         if ($upload) {
             make_thumb($path . $image['name_for_listing'], $path . $image['name'], HEIGHT_FOR_POST_LISTING, WIDTH_FOR_POST_LISTING);
             make_thumb($path . $image['name_for_detail_listing'], $path . $image['name'], HEIGHT_FOR_POST_DETAILS, WIDTH_FOR_POST_DETAILS);
             $this->db->where("id", $id);
             $this->db->update("posts", array("img" => $image['name']));
         }
     }
     $this->db->delete('post_belongs_to_tags', array('post_id' => $id));
     if (!empty($data['tag'])) {
         $tags = $data['tag'];
         $i = 0;
         foreach ($tags as $tag) {
             $is_tag_exist = $this->db->get_where("tags", array("tag" => $tag))->row_array();
             if (!empty($is_tag_exist)) {
                 $post_tags[$i]["tag_id"] = $is_tag_exist['id'];
                 $post_tags[$i]["post_id"] = $id;
             } else {
                 $tag_id = $this->create_tag($tag);
                 $post_tags[$i]['tag_id'] = $tag_id;
                 $post_tags[$i]["post_id"] = $id;
             }
             $i++;
         }
         if (!empty($post_tags)) {
             $this->db->insert_batch("post_belongs_to_tags", $post_tags);
         }
     }
     $this->db->delete('post_belongs_to_topics', array('post_id' => $id));
     if (!empty($data['topic'])) {
         $j = 0;
         foreach ($data['topic'] as $topic) {
             $topic_data = $this->db->get_where("topics", array("topic" => $topic))->row_array();
             if (!empty($topic_data)) {
                 $topic_array[$j]["topic_id"] = $topic_data["id"];
                 $topic_array[$j]["post_id"] = $id;
             } else {
                 $topic_id = $this->create_topic($topic);
                 $this->db->insert("topics_belongs_to_category", array("topic_id" => $topic_id, "category_id" => $data["category_id"]));
                 $topic_array[$j]["topic_id"] = $topic_id;
                 $topic_array[$j]["post_id"] = $id;
             }
             $j++;
         }
         if (!empty($topic_array)) {
             $this->db->insert_batch("post_belongs_to_topics", $topic_array);
         }
     }
     if ($insert_partial_data) {
         $response["rc"] = TRUE;
         $response["msg"] = "Post updated successfully";
     } else {
         $response["rc"] = FALSE;
         $response["msg"] = "Error while updating post";
     }
     return $response;
 }
开发者ID:gorgeousdreams,项目名称:Codeigniter-datatech,代码行数:81,代码来源:Post_model.php

示例4: minimg

function minimg($amg, $prm)
{
    if ($prm == 'no') {
        return;
    }
    $mg = first_img($amg);
    if ($mg) {
        return make_thumb($mg, $prm);
    } elseif (rstr(87)) {
        return mini_empty($prm);
    }
}
开发者ID:philum,项目名称:cms,代码行数:12,代码来源:spe.php

示例5: imagecreatetruecolor

        $imgcreatefrom = "ImageCreateFromJPEG";
    }
    if ($arr_image_details[2] == 3) {
        $imgt = "ImagePNG";
        $imgcreatefrom = "ImageCreateFromPNG";
    }
    if ($imgt) {
        $source_image = $imgcreatefrom($src);
        $new_image = imagecreatetruecolor($desired_width, $desired_height);
        /* copy source image at a resized size */
        imagecopyresampled($new_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $original_width, $original_height);
        /* create the physical thumbnail image to its destination */
        $imgt($new_image, $dest . $thumb_name . $ext);
    }
}
$imagesArr = FilterImages(Readir($imagesDirPath), $imageExt);
$imagesResort = array();
$imagesMeta = array();
foreach ($imagesArr as $key => $value) {
    array_push($imagesResort, $value);
}
foreach ($imagesResort as $key => $value) {
    $ext = pathinfo($value, PATHINFO_EXTENSION);
    $path = $imagesDirPath . $value;
    list($width, $height) = getimagesize($path);
    $imgsize = filesize($path) / 1000;
    make_thumb($path, $thumbPath, 80);
    $imagesMeta[] = array("filename" => $value, "width" => $width, "height" => $height, "filesize" => $imgsize, "filepath" => $path, "thumbpath" => $thumbPath . basename($value, ".{$ext}") . '_thumb.' . $ext, "description" => "some description");
}
$json = json_encode($imagesMeta);
file_put_contents('data.json', $json);
开发者ID:kezoo,项目名称:d3-image-gallery,代码行数:31,代码来源:make_images_data.php

示例6: affiche_prod

function affiche_prod($v, $id)
{
    if (!is_numeric($v)) {
        $v = id_of_suj($v);
    }
    list($day, $frm, $suj, $img, $nod, $thm, $lu, $re) = pecho_arts($v);
    $p["suj"] = $suj;
    $p["img"] = first_img($img);
    $p["thumb"] = make_thumb(first_img($img), "no");
    $p["id"] = $v;
    $p["sty"] = "panel";
    $chsup = explode(" ", $_SESSION['prmb'][18]);
    foreach ($chsup as $cat) {
        $va = sql('msg', 'qdd', 'v', 'ib="' . $v . '" AND val="' . $cat . '"');
        $ct = $cat == 'prix' ? 'price' : $cat;
        if ($va) {
            $p[$ct] = $cat . ': ' . trim($va);
        }
    }
    $p["add2cart"] = ljb("txtbox", "SaveJ", 'cart_shop___' . $v, "add");
    return template($p, 'products');
}
开发者ID:philum,项目名称:cms,代码行数:22,代码来源:shop.php

示例7: addScreenshot

 public function addScreenshot($fileData)
 {
     $file = $fileData["tmp_name"];
     $name = $fileData["name"];
     $dirName = dirname(__DIR__) . '/files/screenshots/' . $this->getId() . '/';
     $targetName = $dirName . $this->getScreenshotCount() . '.png';
     $thumbName = $dirName . $this->getScreenshotCount() . '_thumb.png';
     $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
     if (!is_dir($dirName)) {
         mkdir($dirName, 0777, true);
     }
     if ($ext == "jpg" || $ext == "jpeg") {
         imagepng(imagecreatefromstring(file_get_contents($file)), $targetName);
     } else {
         if ($ext == "png") {
             rename($file, $targetName);
         } else {
             return 1;
         }
     }
     make_thumb($targetName, $thumbName, 150);
     chmod($targetName, "0777");
     chmod($thumbName, "0777");
     $db = new DatabaseManager();
     $db->query("UPDATE `addon_addons` SET `screenshots`=" . ($this->getScreenshotCount() + 1) . " WHERE id= " . $this->id . "");
     echo $db->fetchMysqli()->error;
     $this->screenshots++;
 }
开发者ID:hoff121324,项目名称:GlassWebsite,代码行数:28,代码来源:AddonObject.php

示例8: uploadNewPics

function uploadNewPics($overRideThumb = false)
{
    global $config;
    $thumbOnly = $config->uploadThumbOnly;
    $PicIDs = array();
    if ($thumbOnly && !$overRideThumb) {
        $query = "select MID,FileName,ThumbUpload,FullUpload,UNIX_TIMESTAMP(MotionTime) MotionTime from Motion where ThumbUpload=0";
        $result = getSQLResult("uploadNewPics 1", $query);
        for ($row = $result->fetch_object(); $row; $row = $result->fetch_object()) {
            $PicIDs[$row->MID] = array('Filename' => $row->FileName, 'PictureTime' => $row->MotionTime);
        }
        foreach ($PicIDs as $PicID => $values) {
            $filename = $values["Filename"];
            make_thumb($filename, "/dev/shm/upload/thumb.jpg", 240);
            $pic = file_get_contents("/dev/shm/upload/thumb.jpg");
            $upload = uploadPic($pic, $values['PictureTime'], true, $PicID);
            if ($upload) {
                $query = "update Motion set ThumbUpload=1 where MID=?";
                $result = execSQL("interact,uploadNewPics {$PicID}", $query, "i", $PicID);
            }
        }
    } else {
        $query = "select MID,FileName,ThumbUpload,FullUpload,UNIX_TIMESTAMP(MotionTime) MotionTime from Motion where FullUpload=0";
        $result = getSQLResult("uploadNewPics 2", $query);
        for ($row = $result->fetch_object(); $row; $row = $result->fetch_object()) {
            $PicIDs[$row->MID] = array('Filename' => $row->FileName, 'PictureTime' => $row->MotionTime);
        }
        foreach ($PicIDs as $PicID => $values) {
            $filename = $values["Filename"];
            $pic = file_get_contents($filename);
            logMessage("Found pic to upload PicID={$PicID} filename={$filename}, size=" . strlen($pic));
            $upload = uploadPic($pic, $values['PictureTime'], false, $PicID);
            if ($upload) {
                $query = "update Motion set ThumbUpload=1,FullUpload=1 where MID=?";
                $result = execSQL("interact,uploadNewPics {$PicID}", $query, "i", $PicID);
            }
        }
    }
}
开发者ID:121mhz,项目名称:naboor,代码行数:39,代码来源:interact.php

示例9: time

         } else {
             //we will give an unique name, for example the time in unix time format
             $image_name = time();
             //the new name will be containing the full path where will be stored (images folder)
             $master_name = $img_base_dir . 'temp/masters/' . $image_name . '.' . $extension;
             $copied = copy($_FILES[$fileElementName]['tmp_name'], $master_name);
             //we verify if the image has been uploaded, and print error instead
             if (!$copied) {
                 $error .= 'Copy unsuccessfull!';
                 $errors = 1;
             } else {
                 // the new thumbnail image will be placed in images/thumbs/ folder
                 $thumb_name = $img_base_dir . 'temp/thumbs/' . $image_name . '_350.' . $extension;
                 // call the function that will create the thumbnail. The function will get as parameters
                 //the image name, the thumbnail name and the width and height desired for the thumbnail
                 $thumb = make_thumb($master_name, $thumb_name, WIDTH, HEIGHT);
             }
         }
     }
 }
 //--------- END SECOND SCRIPT --------------------------------------------------------------------
 //return variables to javascript
 $filename = $_FILES[$fileElementName]['name'];
 $filesize = $sizekb;
 $fileloc = $thumb_name;
 //for security reason, we force to remove all uploaded file
 @unlink($_FILES[$fileElementName]);
 //image dimensions
 $masterWH = getimagesize($master_name);
 $masterW = $masterWH[0];
 $masterH = $masterWH[1];
开发者ID:binaryinfotech,项目名称:jQuery-Ajax-Thumbnail-Image-Upload,代码行数:31,代码来源:phpUploadImage.php

示例10: file_handler

function file_handler()
{
    list($uploads_dir, $thumbs_dir) = setup_dir();
    $files = $_FILES['files'];
    $results = array();
    foreach ($files['error'] as $key => $error) {
        $result = isset($_POST['qid']) ? array('qid' => $_POST['qid']) : array();
        $name = escape_special_char($files['name'][$key]);
        $host = get_cdn();
        if ($error == UPLOAD_ERR_OK) {
            if ($files['size'][$key] > get_size_limit()) {
                $result['status'] = 'failed';
                $result['err'] = 'size_limit';
            } else {
                $temp = $files['tmp_name'][$key];
                if ($duplicate = is_duplicate($temp)) {
                    $result['status'] = 'success';
                    $result['thumb'] = ($duplicate['thumb'] == 'none' ? '' : $host) . $duplicate['thumb'];
                    $result['path'] = $host . $duplicate['path'];
                    $result['name'] = $duplicate['name'];
                    $result['width'] = $duplicate['width'];
                    $result['height'] = $duplicate['height'];
                    $result['exlong'] = $duplicate['exlong'];
                    $result['extiny'] = $duplicate['extiny'];
                } else {
                    $mime = file_mime_type($temp);
                    switch ($mime) {
                        case 'image/jpeg':
                            if (!preg_match('/\\.(jpg|jpeg|jpe|jfif|jfi|jif)$/i', $name)) {
                                $name .= '.jpg';
                            }
                            break;
                        case 'image/png':
                            if (!preg_match('/\\.(png)$/i', $name)) {
                                $name .= '.png';
                            }
                            break;
                        case 'image/gif':
                            if (!preg_match('/\\.(gif)$/i', $name)) {
                                $name .= '.gif';
                            }
                            break;
                        case 'image/svg+xml':
                            if (!preg_match('/\\.(svg)$/i', $name)) {
                                $name .= '.svg';
                            }
                            break;
                        default:
                            $result['status'] = 'failed';
                            $result['err'] = 'wrong_type';
                    }
                    if (!isset($result['status']) || !$result['status'] == 'failed') {
                        $name = rename_if_exists($name, $uploads_dir);
                        $path = "{$uploads_dir}/{$name}";
                        if (!move_uploaded_file($temp, ABSPATH . '/' . $path)) {
                            $result['status'] = 'failed';
                            $result['err'] = 'write_prohibited';
                        } else {
                            watermark($path);
                            $thumb = make_thumb($name, $path, $thumbs_dir);
                            if ($duplicate = duplicate_hash($name, $path, $thumb)) {
                                $result['status'] = 'success';
                            } else {
                                $result['status'] = 'error';
                                $result['err'] = 'fail_duplicate';
                            }
                            $result['path'] = $host . $path;
                            $result['name'] = $name;
                            $result['thumb'] = $thumb['generated'] ? $host . $thumb['path'] : 'none';
                            if (isset($thumb['width'])) {
                                $result['width'] = $thumb['width'];
                                $result['height'] = $thumb['height'];
                                $result['exlong'] = $thumb['exlong'];
                                $result['extiny'] = $thumb['extiny'];
                            }
                        }
                    }
                }
            }
        } else {
            switch ($error) {
                case UPLOAD_ERR_INI_SIZE:
                    $result['status'] = 'failed';
                    $result['err'] = 'php_upload_size_limit';
                    break;
                case UPLOAD_ERR_FORM_SIZE:
                    $result['status'] = 'failed';
                    $result['err'] = 'size_limit';
                    break;
                case UPLOAD_ERR_PARTIAL:
                    $result['status'] = 'failed';
                    $result['err'] = 'part_upload';
                    break;
                case UPLOAD_ERR_NO_FILE:
                    $result['status'] = 'failed';
                    $result['err'] = 'no_file';
                    break;
                case UPLOAD_ERR_NO_TMP_DIR:
                    $result['status'] = 'failed';
                    $result['err'] = 'no_tmp';
//.........这里部分代码省略.........
开发者ID:ungc0,项目名称:three5six,代码行数:101,代码来源:functions.upload.php

示例11: confirm

 echo "<div class='thumbnail'>";
 // show the delete button only in edit mode, not in view mode
 if ($_GET['mode'] === 'edit') {
     echo "<a class='align_right' href='app/delete_file.php?id=" . $uploads_data['id'] . "&type=" . $uploads_data['type'] . "&item_id=" . $uploads_data['item_id'] . "' onClick=\"return confirm('Delete this file ?');\">";
     echo "<img src='img/small-trash.png' title='delete' alt='delete' /></a>";
 }
 // end if it is in edit mode
 // get file extension
 $ext = filter_var(Tools::getExt($uploads_data['real_name']), FILTER_SANITIZE_STRING);
 $filepath = 'uploads/' . $uploads_data['long_name'];
 $thumbpath = $filepath . '_th.jpg';
 // list of extensions with a corresponding img/thumb-*.png image
 $common_extensions = array('avi', 'csv', 'doc', 'docx', 'mov', 'pdf', 'ppt', 'rar', 'xls', 'xlsx', 'zip');
 // Make thumbnail only if it isn't done already
 if (!file_exists($thumbpath)) {
     make_thumb($filepath, $ext, $thumbpath, 100);
 }
 // only display the thumbnail if the file is here
 if (file_exists($thumbpath) && preg_match('/(jpg|jpeg|png|gif)$/i', $ext)) {
     // we add rel='gallery' to the images for fancybox to display it as an album (possibility to go next/previous)
     echo "<a href='uploads/" . $uploads_data['long_name'] . "' class='fancybox' rel='gallery' ";
     if ($uploads_data['comment'] != 'Click to add a comment') {
         echo "title='" . $uploads_data['comment'] . "'";
     }
     echo "><img class='thumb' src='" . $thumbpath . "' alt='thumbnail' /></a>";
     // not an image
 } elseif (in_array($ext, $common_extensions)) {
     echo "<img class='thumb' src='img/thumb-" . $ext . ".png' alt='' />";
     // special case for mol files
 } elseif ($ext === 'mol' && $_SESSION['prefs']['chem_editor'] && $_GET['mode'] === 'view') {
     // we need to escape \n in the mol file or we get unterminated string literal error in JS
开发者ID:corcre,项目名称:elabftw,代码行数:31,代码来源:display_file.php

示例12: define

<?php

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    define("WIDTH_I", "240");
    define("HEIGHT_I", "240");
    $fileName = $_FILES["pic"]["name"];
    $fileTmpLoc = $_FILES["pic"]["tmp_name"];
    $moveResult = move_uploaded_file($fileTmpLoc, "{$fileName}");
    if ($moveResult == true) {
        make_thumb($fileName, $fileName, WIDTH_I, HEIGHT_I);
        echo "<div id='data'>" . data_uri($fileName) . "</div>";
        @unlink($fileName);
    }
}
function get_extension($str)
{
    $str = strtolower($str);
    $arr = explode('.', $str);
    if (sizeof($arr) < 2) {
        return "";
    }
    return $str = $arr[sizeof($arr) - 1];
}
function data_uri($file)
{
    $type = get_extension($file);
    $mime = 'image/' . $type;
    $contents = file_get_contents($file);
    $base64 = base64_encode($contents);
    return 'data:' . $mime . ';base64,' . $base64;
}
开发者ID:Covert-Inferno,项目名称:callme,代码行数:31,代码来源:upload.php

示例13: getimagesize

    echo "<script>window.alert('Maaf, hanya mendukung Jpg, jpeg, dan PNG.');\n\t\t\t\t\t\t window.location=('../?v=buku&act=edit&isbn={$Pisbn}&info=FileIsNotSupported')</script>";
    $errors = 1;
} else {
    // get the size of the image in bytes
    // $_FILES[\'image\'][\'tmp_name\'] is the temporary filename of the file in which the uploaded file was stored on the server
    $size = getimagesize($_FILES['image']['tmp_name']);
    $sizekb = filesize($_FILES['image']['tmp_name']);
    //compare the size with the maxim size we defined and print error if bigger
    if ($sizekb > MAX_SIZE * 1024) {
        /*
        			echo '<h1>You have exceeded the size limit!</h1>';
        			echo '<h1>Copy unsuccessfull!</h1>';
        */
        echo "<script>window.alert('Maaf, file harus < 800 KB');\n\t\t\t\t\t\t window.location=('../?v=buku&act=edit&isbn={$Pisbn}&info=ImageTooLarge')</script>";
        $errors = 1;
    } else {
        //we will give an unique name, for example the time in unix time format
        $image_name = time() . '.' . $extension;
        //the new name will be containing the full path where will be stored (images folder)
        $upd = mysql_query("UPDATE buku SET \n\t\t\t\t\t\t\t\t\tjudul='{$Pjudul}',\n                            \t\tnomorEdisi='{$PnomorEdisi}',\n                            \t\tcopyright='{$Pcopyright}',\n                            \t\tdeskripsi='{$Pdeskripsi}',\n                            \t\tIDPenerbit='{$PIDPenerbit}',\n                            \t\tharga='{$Pharga}',\n                            \t\tfileGambar='{$image_name}'\n                            \t\t\n                            \t\tWHERE isbn='{$Pisbn}'\n                            \t\t");
        $newname = "../img/" . $image_name;
        $copied = copy($_FILES['image']['tmp_name'], $newname);
        //we verify if the image has been uploaded, and print error instead
        // the new thumbnail image will be placed in images/thumbs/ folder
        $thumb_name = '../img/thumb_' . $image_name;
        // call the function that will create the thumbnail. The function will get as parameters
        //the image name, the thumbnail name and the width and height desired for the thumbnail
        $thumb = make_thumb($newname, $thumb_name, WIDTH, HEIGHT);
        header("location:../?v=buku&act=edit&isbn={$Pisbn}&info=Success");
    }
}
开发者ID:gepeng05,项目名称:AUB-onlineshop,代码行数:31,代码来源:edit.proses.image.php

示例14: get_files

$thumbs_dir = "../galleries/" . $gallery['name'] . "/gallery-thumbs/";
$thumbs_width = 200;
$thumbs_height = $thumbs_width;
$images_per_row = 15;
/** generate photo gallery **/
$image_files = get_files($images_dir);
if (count($image_files)) {
    $index = 0;
    foreach ($image_files as $index => $file) {
        $index++;
        $thumbnail_image = $thumbs_dir . $file;
        if (!file_exists($thumbnail_image)) {
            $extension = get_file_extension($thumbnail_image);
            $extension = strtolower($extension);
            if ($extension) {
                make_thumb($images_dir . $file, $thumbnail_image, $thumbs_width, $thumbs_height, $extension);
            }
        }
        ?>
        <div class="photo-link"><span class="galleryImage"><img src="<?php 
        echo $thumbnail_image;
        ?>
" style="width:150px; height:150px;" /><input type="checkbox" name="files[]" value="<?php 
        echo $file;
        ?>
" id="<?php 
        echo $file;
        ?>
" /><input name="delete_CheckBox" type="hidden" value="false" /></span></div>
        <?php 
    }
开发者ID:johnsondelbert1,项目名称:prj-illuminate,代码行数:31,代码来源:edit_gallery.php

示例15: mkdir

                $dest_file = $fullDir . '/' . $resumableFilename . '.part' . $resumableChunkNumber;
                // Create the temporary directory
                if (!is_dir($fullDir)) {
                    mkdir($fullDir, 0777, true);
                }
                // Move the temporary file
                if (!move_uploaded_file($file['tmp_name'], $dest_file)) {
                    header('HTTP/1.1 500 Internal Server Error');
                    header('Content-type: text/plain');
                    exit("Error during upload part");
                } else {
                    $storePath = $rootDir . $path . $resumableFilename;
                    $thumbPath = $thumbDir . $path . $resumableFilename;
                    // Check if all the parts present, and assemble the final destination file
                    if (create_file_from_chunks($fullDir, $rootDir . $path, $resumableFilename, $resumableChunkSize, $resumableTotalSize)) {
                        make_thumb($storePath, $thumbPath, $fileExt, 200);
                    } else {
                        header('HTTP/1.1 500 Internal Server Error');
                        header('Content-type: text/plain');
                        exit("Cannot assemble destination file");
                    }
                }
            }
        }
    }
}
/**
 * Check if all the parts exist, and gather all the parts of the file together
 *
 * @param string $tempDir - the temporary directory holding all the parts of the file
 * @param string @rootDir - the root directory where all files are saved too
开发者ID:jundl77,项目名称:FamShare,代码行数:31,代码来源:resumableUploadHandler.php


注:本文中的make_thumb函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。