限时优惠活动
亲爱的苦力吧用户,我们为了回馈新老用户一直以来的鼎力支持,即日起(2025-02-06至2025-03-06)凡是购买苦力吧VIP/充值K币的新老用户,都直接可获得买一送一的优惠馈赠。例如:购买一个月的VIP会员可直接获得两个月的VIP会员;充值100K币可直接获得200K币,以此类推!有任何疑问可联系在线客服,感谢各位用户对苦力吧素材的信任与厚爱,我们将一如既往的给大家上新更多优质的素材源码,祝大家开工大吉、工作顺利、心想事成。

PHP上传图片生成多张不同尺寸缩略图示例源码

所属分类: PHP源码-PHP笔记    2024-01-22 08:51:09

PHP上传图片生成多张不同尺寸缩略图示例源码 ie兼容6

PHP上传图片生成多张不同尺寸缩略图示例源码(共7个文件)

    • image_upload_submit.php
    • functions.php
    • index.php

使用方法

<?php
require_once('functions.php');

if(isset($_FILES['image_file_input']))
 {
	$output['status']=FALSE;
	set_time_limit(0);
	$allowedImageType = array("image/gif",   "image/jpeg",   "image/pjpeg",   "image/png",   "image/x-png"  );
	
	if ($_FILES['image_file_input']["error"] > 0) {
		$output['error']= "File Error";
	}
	elseif (!in_array($_FILES['image_file_input']["type"], $allowedImageType)) {
		$output['error']= "Invalid image format";
	}
	elseif (round($_FILES['image_file_input']["size"] / 1024) > 4096) {
		$output['error']= "Maximum file upload size is exceeded";
	} else {
	    $temp_path = $_FILES['image_file_input']['tmp_name'];
		$file = pathinfo($_FILES['image_file_input']['name']);
		$fileType = $file["extension"];
		$fileName = rand(222, 888) . time() . ".$fileType";
		
		$small_thumbnail_path = "uploads/small/";
		createFolder($small_thumbnail_path);
		$small_thumbnail = $small_thumbnail_path . $fileName;
		
		$medium_thumbnail_path = "uploads/medium/";
		createFolder($medium_thumbnail_path);
		$medium_thumbnail = $medium_thumbnail_path . $fileName;
		
		$large_thumbnail_path = "uploads/large/";
		createFolder($large_thumbnail_path);
		$large_thumbnail = $large_thumbnail_path . $fileName;
		
		$thumb1 = createThumbnail($temp_path, $small_thumbnail,$fileType, 150, 93);
		$thumb2 = createThumbnail($temp_path, $medium_thumbnail, $fileType, 300, 185);
		$thumb3 = createThumbnail($temp_path, $large_thumbnail,$fileType, 550, 340);
				
		if($thumb1 && $thumb2 && $thumb3) {
		    $output['status']=TRUE;
		    $output['small']= $small_thumbnail;
		    $output['medium']= $medium_thumbnail;
        		$output['large']= $large_thumbnail;
		}
	}
	echo json_encode($output);
}
?>	

站长提示:
1. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / PHP笔记

PHP带三种不同显示模式的在线图片管理示例源码

一款在线图片文件管理系统代码,包含三种查看显示模式切换:网格布局、列表布局、幻灯片切换。
  PHP笔记
 4296  0

PHP上传图片生成多张不同尺寸缩略图示例源码

此源码基于PHP+AJAX上传图片二进制文件,ajax请求将调用PHP程序来创建具有指定尺寸的缩略图。在创建缩略图之前,增加了上传文件的验证,如是否为图片扩展名及符合的尺寸大小等。生成了三种尺寸缩略图,各自保存在不同的文件夹。
  PHP笔记
 5292  0

PHP上传图片文件到服务器和MYSQL数据库实现源码

一款基于php+mysql上传图片并输出展示的源代码,核心功能:选择本地图片上传保存到服务器指定文件夹,同时把图片路径和图片名称保存到数据表,此源码无后台管理系统。
  PHP笔记
 2301  0

PHP多文件上传并在线生成ZIP压缩包示例源码

这是一款多文件上传压缩工具类源码,核心功能:可选择多个文件同时上传、同步在线生成ZIP压缩包文件。
  PHP笔记
 1311  0

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论