안녕하세요.
홈피에 등록하면서 인사로 플래쉬에서 파일의 업로드에 대하여 써봅니다.
플래쉬와 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에서 해주시기 바랍니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5777 | 10년 전 | 463 | ||
| 5776 | 10년 전 | 304 | ||
| 5775 | 10년 전 | 240 | ||
| 5774 | 10년 전 | 919 | ||
| 5773 | 10년 전 | 268 | ||
| 5772 | 10년 전 | 304 | ||
| 5771 | 10년 전 | 422 | ||
| 5770 | 10년 전 | 383 | ||
| 5769 | 10년 전 | 223 | ||
| 5768 | 10년 전 | 290 | ||
| 5767 | 10년 전 | 1159 | ||
| 5766 | 10년 전 | 384 | ||
| 5765 | 10년 전 | 463 | ||
| 5764 | 10년 전 | 430 | ||
| 5763 | 10년 전 | 384 | ||
| 5762 | 10년 전 | 232 | ||
| 5761 | 10년 전 | 377 | ||
| 5760 | 10년 전 | 423 | ||
| 5759 | 10년 전 | 838 | ||
| 5758 | 10년 전 | 317 | ||
| 5757 | 10년 전 | 391 | ||
| 5756 | 10년 전 | 353 | ||
| 5755 | 10년 전 | 372 | ||
| 5754 | 10년 전 | 253 | ||
| 5753 | 10년 전 | 434 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기