sub_title
 PHP
제   목 Flex와 PHP를 이용해서 만든 파일업로드 소스
작성자 오렌지 등록일 2007-11-28 20:09:09 조회수 9,101
아래 코드는 Flex와 PHP를 이용해서 파일 업로드를 구현한 것이라고 하네요-_-

FileUpDown.mxml (Language : xml)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
 <mx:Script>
  <![CDATA[
   import mx.controls.Alert;
   
   private var fr:FileReference;;

   public function Download():void {
 
    fr = new FileReference();   
    fr.addEventListener(Event.OPEN,onOpenFile);
    fr.addEventListener(ProgressEvent.PROGRESS,onFileProgress);
    fr.addEventListener(Event.COMPLETE,onCompleteDownload);
   
    var request:URLRequest = new URLRequest();
    request.url = "rank.tar.gz";
   
    try {
     fr.download(request);
    } catch (e:SecurityError){
     Alert.show(e.toString());
    }
   }

   public function onOpenFile(event:Event):void {
    dpg.label = '다운로드 %3%%';
   }
   
   public function onCompleteDownload(event:Event):void {
    Alert.show('다운로드 완료');
   }
   
   public function onFileProgress(event:ProgressEvent):void {
    dpg.setProgress(event.bytesLoaded,event.bytesTotal);
   }
   
   public function Upload():void {
   
    fr = new FileReference();
    fr.addEventListener(Event.SELECT,onUploadSelectFile);
    fr.addEventListener(Event.OPEN,onUploadOpenFile);
    fr.addEventListener(ProgressEvent.PROGRESS,onUploadFileProgress);
    fr.addEventListener(Event.COMPLETE,onUploadCompleteDownload);

    var imgFilter:FileFilter = new FileFilter("Images(*.png;*.gif;*.jpg)","*.png;*.gif;*.jpg");
    var arcFilter:FileFilter = new FileFilter("Archives(*.zip;*.gz;*.tar)","*.zip;*.gz;*.tar");
    var allFilter:FileFilter = new FileFilter("All(*.*)","*.*");
    fr.browse([imgFilter,arcFilter,allFilter]); 

   }

   public function onUploadSelectFile(event:Event):void {
    var request:URLRequest = new URLRequest();
    request.url = "upload.php";
       
    try {
     fr.upload(request,"file");
    } catch (e:SecurityError){
     Alert.show(e.toString());
    }   
   }
   
   public function onUploadOpenFile(event:Event):void {
    upg.label = '업로드 %3%%';
   }
   
   public function onUploadCompleteDownload(event:Event):void {
    Alert.show('업로드 완료');
   }
   
   public function onUploadFileProgress(event:ProgressEvent):void {
    upg.setProgress(event.bytesLoaded,event.bytesTotal);
   }
  ]]>

 </mx:Script>
 <mx:Button x="10" y="10" label="Dowload" click="Download()"/>
 <mx:Label id="filepg" x="93" y="12"/>
 <mx:ProgressBar x="10" y="38" width="351" label="" id="dpg" mode="manual"/>
 <mx:ProgressBar x="10" y="110" width="351" label="" id="upg" mode="manual"/>
 <mx:Button x="10" y="80" label="Upload" click="Upload()" width="75"/>
</mx:Application>
 


upload.php (Language : php)
<?
$file_temp = $_FILES['file']['tmp_name'];
$file_name = $_FILES['file']['name'];
$file_size = $_FILES['file']['size'];

$updir = "D:/wwwroot/test/html/upload";

if(!empty($file_name)){
 $filename = sprintf("%s/%s",$updir,$file_name);
 $filename = iconv("UTF-8", "EUC-KR",$filename)// 한글처리

 if(!file_exists($filename)) {
  if(move_uploaded_file($file_temp,$filename)){
  } else {
  }
 }
}

fclose($fp);
?>

 

출처 : http://www.ihelpers.co.kr/programming/t ··· Bag%3Dpg 

 
0
    
 
0
        list
 
※ 짧은 댓글일수록 예의를 갖추어 작성해 주시기 바랍니다.
line
reply cancel
 
번호 제목 글쓴이 추천 조회 날짜
30  PHP 함수 간단 정리   member 웹스톤 0 / 0 8307 2008-08-14
29  PHP 메일(mail) 함수를 이용한 첨부화일 전송하기 첨부파일   admin 웹마당넷 3 / 1 28211 2008-08-02
28  PHP 파일 업로드 보안   member 사라마음 0 / 0 8358 2008-08-02
27  PHP - 파일첨부가 가능한 폼메일러 LeoFormMailer 첨부파일   member 웹스톤 0 / 0 9410 2008-08-01
26  PHP - RSS 리더기   member 파도 0 / 1 8150 2008-07-29
25  PHP 숫자 천자리마다 콤마(쉼표) 찍기   member 높이뜬새 2 / 2 20084 2008-07-29
24  PHP 문자열 연결하기   member 높이뜬새 0 / 0 9404 2008-07-25
23  무조건 알아야 할 PHP 속도 테스트 14 가지   member 웹스톤 1 / 0 20633 2008-06-16
22  PHP 문자열중 숫자만 추출하기   member 높이뜬새 0 / 0 10291 2008-05-19
21  [설치/설정] 대용량 업로드...   member 컴퓨터존 0 / 0 7069 2008-05-02
20  [PHP] post, get, cookie, session 변수 확인   member 컴퓨터존 0 / 0 9828 2008-05-02
19  PHP Caching to speed up   member 컴퓨터존 0 / 0 7955 2008-05-02
18  PHP 현재 접속자 현황 보여주기   member 컴퓨터존 0 / 0 9245 2008-04-08
17  PHP 한글 레퍼런스   member 컴퓨터존 0 / 0 8573 2008-04-05
16  Flex와 PHP를 이용해서 만든 파일업로드 소스   member 오렌지 0 / 0 9101 2007-11-28
15  프레임(frame) 새로고침 할때 페이지 유지하기   member 웹스톤 0 / 0 10403 2007-11-15
14  [설치/설정] 대용량 업로드...   member 웹스톤 0 / 0 7552 2007-11-15
13  PHP에서 성능 개선을 위한 유용한 팁   member 웹스톤 0 / 0 10059 2007-11-15
12  PHP 버블소트 알고리즘   member 웹스톤 0 / 0 7114 2007-11-14
11  Oracle/PHP 환경의 트랜잭션 관리 이미지   member 웹돌이 0 / 0 45899 2007-10-09
10  FTP 서버 설치 및 관리   member 웹돌이 0 / 0 10029 2007-10-09
9  리눅스 ftp 명령어 모음   member 웹돌이 0 / 0 8002 2007-10-09
8  게시판검색이나 쇼핑몰에 유용한 자바스크립트   member 웹돌이 0 / 0 8244 2007-10-09
7  변수속도 테스트   member 웹돌이 0 / 0 6989 2007-10-09
6  PHP에서 접속자 IP 알아내기   member 높이뜬새 0 / 0 11208 2007-09-08
write
button [1] [2] [4] button