안녕하세요. 전에 이어서 플래쉬에서의 파일업로드를 구체적으로 설명하죠.
따라해보세요.
System.security.allowDomain("http://localhost/");//이 도메인을 설정해주지 않으면 PHP쪽에서 파일을 업로드 받지 못합니다. 그러니 여기서 http://localhost/는 PHP파일이 있는 웹서버의 url이지요. 전 내 컴에 php서버를 구축했으니까localhost로 됩니다.
import flash.net.FileReference;//파일을 다르기위해서 필요한 패키지의 참조입니다.
var allTypes:Array = new Array();
var imageTypes:Object = new Object();
imageTypes.description = "Images (*.jpg, *.jpeg, *.gif, *.png)";
imageTypes.extension = "*.jpg; *.jpeg; *.gif; *.png";
allTypes.push(imageTypes);//파일의 타입을 어레이로 설정합니다.
var listener:Object = new Object();//파일참조클래스변수를 위한 리스너를 만듭니다. 꼭이렇게 하는거 아니고요.
listener.onSelect = function(file:FileReference):Void {
trace("onSelect: " + file.name);
trace(this);
if(!file.upload("http://localhost/fileupload.php")) {//파일업로드합니다.
trace("Upload dialog failed to open.");
}
}
listener.onCancel = function(file:FileReference):Void {//파일선택취소했을때처리
trace("onCancel");
}
listener.onOpen = function(file:FileReference):Void {//파일열기했을떄처리
trace("onOpen: " + file.name);
}
listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
}
listener.onComplete = function(file:FileReference):Void {//업로드완성
trace("onComplete: " + file.name);
}
listener.onHTTPError = function(file:FileReference):Void {
trace("onHTTPError: " + file.name);
}
listener.onIOError = function(file:FileReference):Void {
trace("onIOError: " + file.name);
}
listener.onSecurityError = function(file:FileReference, errorString:String):Void {
trace("onSecurityError: " + file.name + " errorString: " + errorString);
}
var fileRef:FileReference = new FileReference();
fileRef.addListener(listener);
fileRef.browse(allTypes);//파일다이얼로그열기 여기서 파일을 선택하지요.
구체적인 설명이 요구되시면 문의 부탁...
안녕
게시글 목록
| 번호 | 제목 |
|---|---|
| 12386 |
PHP
메타태그 주요정리 입니다.
|
| 12385 |
JavaScript
광고나 공지사항 띄울때 다음부터 이창을 띄우지 않기 입니다.
|
| 12384 |
MySQL
테이블 생성, 컬럼 추가, 삭제, 수정
|
| 12380 |
JavaScript
입력값을 형식에 맞게 해주는 플러그인이네요
3
|
| 12379 |
JavaScript
팝업창에서 오늘 하루 이 페이지 열지 않기 체크박스 사용입니다.
|
| 12378 |
JavaScript
팝업창 하루에 한번만 열기 입니다
|
| 12377 | |
| 12376 |
jQuery
유투브 관련 플러그인
|
| 12375 |
jQuery
input 태그에 readonly 추가하는 방법
|
| 12374 | |
| 12373 | |
| 12372 |
jQuery
자주 쓰이는 Jquery 팁 20가지 입니다.
|
| 12371 |
jQuery
jQuery 오른쪽 퀵메뉴 입니다.
|
| 12369 |
jQuery
textarea 글자수 카운트 입니다.
1
|
| 368 | |
| 12368 |
jQuery
ifrmae 자동 리사이즈 jQuery 입니다.
|
| 12367 |
jQuery
슬라이딩 형태로 보여주기 입니다.
|
| 12366 |
jQuery
라인 그래프 그리기 입니다.
|
| 12365 |
jQuery
콤보박스관련 플러그인
|
| 12363 |
MySQL
MySQL 기본 명령어 정리 입니다.
1
|
| 12362 |
MySQL
MySQL 한글 정렬하기 입니다.
|
| 12361 |
MySQL
그림을 MySQL DB에 저장하는 방법
|
| 12360 |
JavaScript
엑셀 흉내내기
|
| 12359 | |
| 12358 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기