限时优惠活动
亲爱的苦力吧用户,我们为了回馈新老用户一直以来的鼎力支持,即日起(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+AJAX上传图片二进制文件,ajax请求将调用PHP程序来创建具有指定尺寸的缩略图。在创建缩略图之前,增加了上传文件的验证,如是否为图片扩展名及符合的尺寸大小等。生成了三种尺寸缩略图,各自保存在不同的文件夹。
  PHP笔记
 6350  0

PHP自定义SVG图标表单验证实现源码

这是一款类似于谷歌网站常用的图片选择验证码模块,根据随机给出的事物名称,选择一个正确的图片。一般常用于表单填写模块中,为了防止恶意提交或机器人频繁发送,从而开发出来的验证码机制。
  PHP笔记
 2436  0

PHP简单的悬浮于页面右侧在线购物车源码

一款php购物车实现示例代码,核心功能:商品列表、加入购物车、清空购物车。
  PHP笔记
 8524  0

PHP+AJAX创建的动态网页在线日历

一款基于php日期函数实现的网页日历,通过PHP日历类,使用PHP日期函数计算日历数据。
  PHP笔记
 7387  0

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

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