찾다
php教程php手册Flash上传文件

上传

一直想搞这个功能, 想了很多歪门邪道, 未果!
昨天突然在 blueidea 上看到关于 Flash 8 的新特性 (虽然早就装上了 Flash 8 但一直没有仔细研究, 真是惭愧 :p) 中介绍了 flash 8 提供了上载和下载的接口, 马上下去研究了一下, 果然不错. 虽然上传还是需要后台脚本的支持, 但也足够我美上一阵子的了 :D
下面是研究成果, 不敢独享, 拿出来示众 :D
UploadFile.fla

CODE:
// 加载包
import flash.net.FileReference;
// 定义主角 FileReference 对象
var fileRef:FileReference = new FileReference();
// 定义 监听对象
var fileLsn:Object = new Object();
// 定义 文件类型数组 FileReference 对象的 browse 方法的参数
// description: 描述
// extension : 扩展名列表
var fileTyp:Array = new Array({description:"Image files", extension:"*.jpg;*.gif"}, {description:"Document files", extension:"*.txt;*.doc"});
btnBrowse.onRelease = function() {
// 打开 "选择文件" 对话框
fileRef.browse(fileTyp);
};
btnUpload.onRelease = function() {
// 开始上传
fileRef.upload("uploadFile.php");
};
btnClear.onRelease = function() {
strState.text = "";
};
// 选择文件事件
fileLsn.onSelect = function(file:FileReference) {
strState.text += "onSelect '"+file.name+"'\n";
};
// 取消选择
fileLsn.onCancel = function(file:FileReference) {
strState.text += "Cancel!\n";
};
// 打开文件开始上传
fileLsn.onOpen = function(file:FileReference) {
strState.text += "Uploading... '"+file.name+"'\n";
};
// 上传成功
fileLsn.onComplete = function(file:FileReference) {
strState.text += "File '"+file.name+"' upload successfull!\n";
};
// 上传过程
fileLsn.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
strState.text += "onProgress: "+file.name+" with bytesLoaded: "+bytesLoaded+" bytesTotal: "+bytesTotal+"\n";
};
// HTTP 错误
fileLsn.onHTTPError = function(file:FileReference, httpError:Number) {
strState.text += "HTTP ERROR: "+httpError+"\n";
};
// IO 错误
fileLsn.onIOError = function(file:FileReference):Void {
strState.text += "IO Error: "+file.name+"\n";
};
// 安全错误
fileLsn.onSecurityError = function(file:FileReference, errorString:String):Void {
strState.text += "onSecurityError: "+file.name+" errorString: "+errorString;
};
// 绑定监听器
fileRef.addListener(fileLsn);
// 其他属性或事件请参考帮助中关于 FileReference 对象的章节


UploadFile.php

CODE:
// Flash 传递的文件表单 name 属性为 Filedata
$fileName = $_FILES["Filedata"]["name"];
$file = $_FILES["Filedata"]["tmp_name"];
$path = "uploadFiles/";
if (move_uploaded_file($file, $path . $fileName)){
// echo 1;
}else{
// echo 0;
}
/*
* 只要上传代码就够了
* Flash 似乎不判断该文件的返回值
* 即使该文件报告错 Flash 也无法分析
* 所以最好保证这个文件不会出错
*/
?>
源文件下载
 



성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
4 몇 주 전By尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

WebStorm Mac 버전

WebStorm Mac 버전

유용한 JavaScript 개발 도구

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

DVWA

DVWA

DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

Atom Editor Mac 버전 다운로드

Atom Editor Mac 버전 다운로드

가장 인기 있는 오픈 소스 편집기

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구