php flash 图片上传,flash + php 文件上传

import flash.net.FileFilter;

import flash.net.FileReferenceList;

import fl.controls.Button;

import flash.events.MouseEvent;

import flash.events.Event;

import flash.events.ProgressEvent;

import flash.events.HTTPStatusEvent;

import flash.display.Loader;

import flash.net.URLRequest;

var choose_button:Button=new Button();

var upload_button:Button=new Button();

var loader:Loader=new Loader();

var reference_list:FileReferenceList=new FileReferenceList();

var url:URLRequest=new URLRequest("http://localhost/flashupload.php");

choose_button.label="选择文件";

upload_button.label="上传文件";

upload_button.move(100,50);

addChild(choose_button);

choose_button.move(300,100);

addChild(upload_button);

addChild(loader);

choose_button.addEventListener(MouseEvent.CLICK,choose_file);

upload_button.addEventListener(MouseEvent.CLICK,upload_start);

reference_list.addEventListener(Event.SELECT, selectHandle);

reference_list.addEventListener(Event.CANCEL, cancelHandle);

//reference_list.addEventListener(ProgressEvent.PROGRESS, progressHandler);

//reference_list.addEventListener(Event.COMPLETE, completeHandle);

//reference_list.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandle);

loader.contentLoaderInfo.addEventListener(Event.COMPLETE,load_complete);

function progressHandler(evt:ProgressEvent):void{

trace("ProgressEvent");

trace(evt.target.name+"="+evt.bytesLoaded)

}

function load_complete(evt:Event):void{

trace("load_complete");

}

function selectHandle(evt:Event):void{

trace("select file successfully");

trace("你选择了"+evt.target.fileList.length+"文件")

for(var i:int=0;i

trace(evt.target.fileList[i].name);

evt.target.fileList[i].addEventListener(ProgressEvent.PROGRESS, progressHandler);

evt.target.fileList[i].addEventListener(Event.COMPLETE, completeHandle);

evt.target.fileList[i].load();

}

//trace("type"+evt.target.fileList[0].type);

}

function cancelHandle(evt:Event):void{

trace("cnacel the file");

}

function httpStatusHandle(evt:HTTPStatusEvent):void{

trace("open file");

}

function completeHandle(evt:Event):void{

trace("completehandle");

var pic_loader:Loader=new Loader();

pic_loader.loadBytes(evt.target.data);

//loader.addChild(pic_loader);

this.addChild(pic_loader);

}

function choose_file(evt:MouseEvent):void{

reference_list.browse(get_file_type());

}

function get_file_type():Array{

var file_array=new Array();

file_array.push(new FileFilter("Images","*.jpg;*.jpeg;*.gif;*.png;*.rar;*.iso"));

return file_array;

}

function upload_start(evt:MouseEvent):void{

for(var i:int=0;i

reference_list.fileList[i].upload(url);

}

}

php ///

$uploaddir = 'aa/';

$filename = date("Ymdhis").rand(100,999);

$uploadfile = $uploaddir .$filename.substr($_FILES['Filedata']["name"],strrpos($_FILES['Filedata']["name"],"."));

$temploadfile = $_FILES['Filedata']['tmp_name'];

file_put_contents("catcah.txt",$_FILES['Filedata']['tmp_name']);

move_uploaded_file($temploadfile , $uploadfile);

?>

什么是SWFUpload?   SWFUpload是一个客户端文件上传工具,最初由Vinterwebb.se开发,它通过整合Flash与JavaScript技术为WEB开发者提供了一个具有丰富功能继而超越传统标签的文件上传模式。 [编辑本段]SWFUpload的主要特点   * 可以同时上传多个文件;   * 类似AJAX的无刷新上传;   * 可以显示上传进度;   * 良好的浏览器兼容性;   * 兼容其他JavaScript库 (例如:jQuery, Prototype等);   * 支持Flash 8和Flash 9;   SWFUpload不同于其他基于Flash构建的上传工具,它有着优雅的代码设计,开发者可以利用XHTML、CSS和JavaScript来随心所欲的定制它在浏览器下的外观;它还提供了一组简明的JavaScript事件,借助它们开发者可以方便的在文件上传过程中更新页面内容来营造各种动态效果。   在使用SWFUpload之前,请确认你具备一定的JavaScript和DOM知识。在实际开发中,大部分的错误都是由于错误的设置和低劣的Event Handlers处理程序所造成的。 [编辑本段]文档中文翻译   http://www.v-sky.com/doc/swfupload/v2.1.0/Documentation.html [编辑本段]效果演示   * Classic Form Demo http://demo.swfupload.org/formsdemo ;   * Features Demo http://demo.swfupload.org/featuresdemo ;   * Application Demo http://demo.swfupload.org/applicationdemo ;   * v1.0.2 Plugin Demo http://demo.swfupload.org/v102demo ; [编辑本段]选择合适的Flash控件   在发行包(SWFUpload v2)中含有2个版本的Flash控件(swfupload_f8.swf 与wfupload_f9.swf),其中第一个版本拥有最佳的兼容性,但是为此损失了部分功能;而第二个版本提供了一些附加的功能但是损失了兼容性。 [编辑本段]SWFUpload的初始化与配置   首先,在页面中引用SWFUpload.js ,如      然后,初始化SWFUpload ,如   var swfu;   window.onload = function () {   swfu = new SWFUpload({   upload_url : "http://www.swfupload.org/upload.php",   flash_url : "http://www.swfupload.org/swfupload_f9.swf", file_size_limit : "20480"   });   };   以下是一个标准的SWFUpload初始化设置所需的参数,你可以根据需要自己进行删减:   {   upload_url : "http://www.swfupload.org/upload.php", 处理上传请求的服务器端脚本URL   file_post_name : "Filedata", 是POST过去的$_FILES的数组名   post_params : {   "post_param_name_1" : "post_param_value_1",   "post_param_name_2" : "post_param_value_2",   "post_param_name_n" : "post_param_value_n"   },   file_types : "*.jpg;*.gif", 允许上传的文件类型   file_types_description: "Web Image Files", 文件类型描述   file_size_limit : "1024", 上传文件体积上限,单位MB   file_upload_limit : 10, 限定用户一次性最多上传多少个文件,在上传过程中,该数字会累加,如果设置为“0”,则表示没有限制   file_queue_limit : 2, 上传队列数量限制,该项通常不需设置,会根据file_upload_limit自动赋值   fl
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值