테스트 사이트 - 개발 중인 베타 버전입니다

플래쉬쪽에서의 파일업로드

· 18년 전 · 3158

안녕하세요. 전에 이어서 플래쉬에서의 파일업로드를 구체적으로 설명하죠.
따라해보세요.
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);//파일다이얼로그열기 여기서 파일을 선택하지요.

구체적인 설명이 요구되시면 문의 부탁...
안녕

[이 게시물은 관리자님에 의해 2011-10-31 16:50:06 Flash에서 이동 됨]

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

게시글 목록

번호 제목
12007
12006
12005
12000
11994
11993
11992
11991
11990
11989
29203
11988
11986
11985
11984
11983
11982
29202
29201
24968
11981
29200
29198
11979
11978
11975
11973
11972
11971
11970
11966
11962
29197
29196
11961
11960
11959
JavaScript 간단PHP(1)
11958
11956
11952
11948
11944
11936
11935
29195
11934
29191
11933
29186
11932
11931
11926
11922
29183
11920
11916
11915
11913
11910
29182
11904
11901
11900
29181
11898
29179
11894
11892
11890
11889
11888
11886
11883
11879
11875
29178
29167
11874
29166
11872
11870
11867
11866
11865
29165
29162
11861
11851
11850
11847
11846
11845
11840
11826
11825
11823
11816
11808
11805
11804
JavaScript <script>