안녕하세요.
홈피에 등록하면서 인사로 플래쉬에서 파일의 업로드에 대하여 써봅니다.
플래쉬와 PHP를 연동하려면 플래쉬쪽에서 파일을 업로드 하고 PHP쪽에서 업로드된파일을 받아 처리합니다.
플래쉬쪽에서의 액션코드를 보면 다음과 같습니다.
System.security.allowDomain("http://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);//파일다이얼로그열기 여기서 파일을 선택하지요.
PHP에서는 다음의 코드를 씁니다.(fileupload.php)
<?php
$f = $HTTP_POST_FILES['Filedata'];
$filename = "1.aa";
if (!copy($a['tmp_name'],$filename)) {
print ("failed to copy $file...<br>\n");
}
?>
위에서 보시는 바와 같이 플래쉬와 PHP는 대단히 쉬워요.
구체적인 설명이 요구되시면 문의 부탁...
안녕
게시판 목록
팁게시판
질문은 상단의 QA에서 해주시기 바랍니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5827 | 9년 전 | 358 | ||
| 5826 | 9년 전 | 345 | ||
| 5825 | 9년 전 | 310 | ||
| 5824 | 9년 전 | 476 | ||
| 5823 | 9년 전 | 476 | ||
| 5822 | 9년 전 | 267 | ||
| 5821 | 9년 전 | 581 | ||
| 5820 | 9년 전 | 886 | ||
| 5819 | 9년 전 | 415 | ||
| 5818 | 9년 전 | 565 | ||
| 5817 |
|
9년 전 | 1362 | |
| 5816 | 9년 전 | 390 | ||
| 5815 | 9년 전 | 367 | ||
| 5814 | 9년 전 | 343 | ||
| 5813 |
|
9년 전 | 1129 | |
| 5812 | 9년 전 | 442 | ||
| 5811 | 9년 전 | 225 | ||
| 5810 | 9년 전 | 256 | ||
| 5809 | 9년 전 | 461 | ||
| 5808 | 9년 전 | 307 | ||
| 5807 | 9년 전 | 275 | ||
| 5806 | 9년 전 | 260 | ||
| 5805 | 9년 전 | 279 | ||
| 5804 | 9년 전 | 276 | ||
| 5803 | 9년 전 | 267 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기