태터데스크
관리자
태터데스크
메시지
저장하였습니다.
THLIFE.net
Home
Tag
MediaLog
LocationLog
Guestbook
Admin
Write
search
Total |
763,075
Today |
75
Yesterday |
167
language/php
2008/01/17 15:49
Flex & PHP 파일 업로드 소스
아래 코드는 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
'
language
>
php
' 카테고리의 다른 글
php 문자열 2차 배열 변환
(0)
2008/02/28
PHP 배열의 원리 - array()
(0)
2008/01/31
php-배열
(0)
2008/01/31
php- explode
(0)
2008/01/31
Flex & PHP 파일 업로드 소스
(0)
2008/01/17
php 메일 (첨부파일가능)
(1)
2008/01/16
Posted by
THLIFE.net
TAG
flex
,
PHP
,
업로드
,
파일
,
플렉스
Trackback
0
Comment
0
TRACKBACK
http://thlife.net/trackback/43
댓글을 달아 주세요
Name
Password
Homepage
secret
«이전
1
...
983
984
985
986
987
988
989
990
991
...
1026
다음»
RSS FEED
THLIFE.net
몇번이라도 좋다. 이 끔찍한 생이여, 다시! -니체
카테고리
분류 전체보기
(1026)
diary
(90)
thlife's diary
(84)
sally's diary
(1)
misc
(136)
my favorite
(5)
scripts
(118)
my favorite things
(10)
english
(2)
australia
(1)
photograph
(71)
u & i & my baby
(48)
family
(3)
their
(7)
gravity
(9)
imagination
(4)
------- [ IT ] -------
(0)
mobile
(34)
ios
(31)
android
(1)
other
(2)
ria
(86)
flex
(80)
air
(4)
html5
(2)
frameworks
(8)
puremvc
(4)
spring
(4)
language
(27)
java
(16)
jsp
(4)
php
(6)
coldfusion
(1)
web
(11)
was
(9)
tomcat
(9)
database
(10)
oracle
(10)
fundamentale
(4)
design pattern
(4)
algorithm
(0)
refactoring
(0)
etc
(34)
------- [ etc ] ----..
(7)
살아가면서 유용한것들
(1)
가벼운 내용들
(1)
events
(5)
------- [ fashion ]..
(326)
collection
(43)
trends & style
(135)
information
(148)
------- [ u.s.a ] --..
(128)
history
(2)
culture
(12)
economy
(19)
events
(95)
- [ financial techno..
(45)
marriage
(4)
credit rating
(8)
finance & economy
(33)
링크
경일어페럴.
춤추는 프로그래머.
하루 또 하루.
Nobody knows....
twitter.
Apple Developer.
음먀의 블로그.
THLIFE.net.
최근에 올라온 글
[iOS] StatusBar를 눌렀는데, Table...
NSString 을 UTF-8로 encode / deco...
[ios4 이상] Photo Library 에서 데...
JSONKit... 만약 정말 빠른 파서를...
최근에 달린 댓글
뒤늦게 보고 정...
김울프
05/11
비밀댓글입니다.
le nom de domaine
04/10
비밀댓글입니다.
check domain name availability
04/09
최근에 받은 트랙백
uk job site.
uk job site
05/16
free insurance...
free insurance..
05/02
tattoo kits.
tattoo kits
04/29
태그목록
행복한경영이야기
flex
플렉스
iPhone
그리다 웨딩촬영
그리다
청담동 그리다 스튜디오
그리다 소호 비교
그리다 스튜디오
Java
티스토리 홈
티스토리 가입하기
댓글을 달아 주세요