代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
PHP
】
swfupload 批量上传
作者:
Dezai.CN
/ 发布于
2011/8/7
/
689
<div>//首先 准备 swfupload 包 //前端用户体验页面 <!DOCTYPE html> <html> <head> <title>SWFUpload Demos - Application Demo</title> <link href="./default.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="./swfupload/swfupload.js"></script> <script type="text/javascript" src="./swfupload/jquery-1.4.js"></script> <script type="text/javascript" src="js/handlers.js"></script> <script type="text/javascript"> $(function(){ $('#btn').bind('click',path);</div> <div>});</div> <div>function path() { var url=''; $('#thumbnails img').each(function(){ url=$(this).attr('id')+'{#@T@#}'+url; }) alert(url); } <div> var swfu; window.onload = function () { swfu = new SWFUpload({ // Backend Settings upload_url: "upload.php", post_params: {"PHPSESSID": "<?php echo session_id(); ?>"},</div> <div> // File Upload Settings file_size_limit : "800", // 2MB 最大容量限制 file_types : "*.jpg", file_types_description : "JPG Images", file_upload_limit : 5,//上传数量限制</div> <div> // Event Handler Settings - these functions as defined in Handlers.js // The handlers are not part of SWFUpload but are part of my website and control how // my website reacts to the SWFUpload events. swfupload_preload_handler : preLoad, swfupload_load_failed_handler : loadFailed, file_queue_error_handler : fileQueueError, file_dialog_complete_handler : fileDialogComplete, upload_progress_handler : uploadProgress, upload_error_handler : uploadError, upload_success_handler : uploadSuccess, upload_complete_handler : uploadComplete,</div> <div> // Button Settings button_image_url : "images/SmallSpyGlassWithTransperancy_17x18.png", button_placeholder_id : "spanButtonPlaceholder", button_width: 200, button_height: 18, button_text : '<span class="button">Select Images <span class="buttonSmall">(800 k Max)[*.jpeg]</span></span>', button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt; } .buttonSmall { font-size: 10pt; }', button_text_top_padding: 0, button_text_left_padding: 18, button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT, button_cursor: SWFUpload.CURSOR.HAND, // Flash Settings flash_url : "./swfupload/swfupload.swf", flash9_url : "./swfupload/swfupload_FP9.swf",</div> <div> custom_settings : { upload_target : "divFileProgressContainer" }, // Debug Settings debug: false }); }; </script> </head> <body> <h2>最多上传5张图片<h2> <form> <div style="width: 200px; height: 18px; border: solid 1px #7FAAFF; background-color: #C5D9FF; padding: 2px;"> <span id="spanButtonPlaceholder"></span> </div> </form> <div id="divFileProgressContainer" style="height: 75px;"></div> <div id="thumbnails" style='width:500px;border:1px solid lime;padding-left:20px'></div> </div> <button id='btn'>提交</button> </body> </html></div> <div>//后台处理页面 upload.php <?php if (isset($_POST["PHPSESSID"])) { session_id($_POST["PHPSESSID"]); } <div>session_start(); ini_set("html_errors", "0");</div> <div>// Check the upload if (!isset($_FILES["Filedata"]) || !is_uploaded_file($_FILES["Filedata"]["tmp_name"]) || $_FILES["Filedata"]["error"] != 0) { echo "ERROR:invalid upload"; exit(0); } <div>// Get the image and create a thumbnail $img = imagecreatefromjpeg($_FILES["Filedata"]["tmp_name"]); if (!$img) { echo "ERROR:could not create image handle ". $_FILES["Filedata"]["tmp_name"]; exit(0); } <div>$width = imageSX($img); $height = imageSY($img);</div> if (!$width || !$height) { echo "ERROR:Invalid width or height"; exit(0); } <div>// Build the thumbnail $target_width = 100; $target_height = 100; $target_ratio = $target_width / $target_height;</div> <div>$img_ratio = $width / $height;</div> if ($target_ratio > $img_ratio) { $new_height = $target_height; $new_width = $img_ratio * $target_height; } else { $new_height = $target_width / $img_ratio; $new_width = $target_width; } if ($new_height > $target_height) { $new_height = $target_height; } if ($new_width > $target_width) { $new_height = $target_width; } <div>$new_img = ImageCreateTrueColor(100, 100); if (<a href="mailto:!@imagefilledrectangle($new_img">!@imagefilledrectangle($new_img</a>, 0, 0, $target_width-1, $target_height-1, 0)) { // Fill the image black echo "ERROR:Could not fill new image"; exit(0); } if (<a href="mailto:!@imagecopyresampled($new_img">!@imagecopyresampled($new_img</a>, $img, ($target_width-$new_width)/2, ($target_height-$new_height)/2, 0, 0, $new_width, $new_height, $width, $height)) { echo "ERROR:Could not resize image"; exit(0); } if (!isset($_SESSION["file_info"])) { $_SESSION["file_info"] = array(); } <div>// Use a output buffering to load the image into a variable ob_start(); imagejpeg($new_img); $imagevariable = ob_get_contents(); ob_end_clean(); $file_id = md5($_FILES["Filedata"]["tmp_name"] + rand()*100000); $_SESSION["file_info"][$file_id] = $imagevariable; //上传图片处理</div> if(!is_dir("uploadimage")) { mkdir("uploadimage"); } $pre_fix=md5('120ask120'); move_uploaded_file($_FILES["Filedata"]["tmp_name"],trim("./uploadimage/".$pre_fix.$file_id.".jpg")); /*图片处理结束*/ echo "FILEID:" . $file_id; // Return the file id to the script ?></div> <div></div> <div></div>
试试其它关键字
批量上传
同语言下
.
用net匹配并替换iOS标准的emoji表情符号
.
处理带Emoji表情的的字符串
.
获取微信昵称时 过滤特殊字符
.
通过判断上传文件的头字符来判断文件的类型
.
模拟百度URL加密解密算法
.
以太坊检查地址是否合法
.
实现crontab解析类
.
获取每个月的开始和结束时间
.
图片上传工具类
.
APP手机应用信息采集
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
Dezai.CN
贡献的其它代码
(
4037
)
.
多线程Socket服务器模块
.
生成随机密码
.
清除浮动样式
.
弹出窗口居中
.
抓取url的函数
.
使用base HTTP验证
.
div模拟iframe嵌入效果
.
通过header转向的方法
.
Session操作类
.
执行sqlite输入插入操作后获得自动编号的ID
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3