Andy E는이를 수행하는 HTML 기반 방법이 없다는 것이 옳습니다 *; 하지만 Flash를 사용하고 싶다면 할 수 있습니다. 다음은 Flash가 설치된 시스템에서 안정적으로 작동합니다. 앱이 iPhone에서 작동해야하는 경우 당연히 대체 HTML 기반 솔루션이 필요합니다.
* ( 2013 년 4 월 22 일 업데이트 : HTML은 이제 HTML5에서이를 지원합니다. 다른 답변을 참조하세요.)
플래시 업로드에는 다른 장점도 있습니다. 플래시는 대용량 파일의 업로드가 진행됨에 따라 진행률 표시 줄을 표시하는 기능을 제공합니다. (내가 틀렸을 수도 있지만, 뒤에서 Flash를 사용함으로써 Gmail이 그렇게하는 방식이라고 확신합니다.)
다음은 사용자가 파일을 선택하여 표시 할 수있는 Flex 4 앱 샘플입니다.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
creationComplete="init()">
<fx:Declarations>
</fx:Declarations>
<s:Button x="10" y="10" label="Choose file..." click="showFilePicker()" />
<mx:Image id="myImage" x="9" y="44"/>
<fx:Script>
<![CDATA[
private var fr:FileReference = new FileReference();
// Called when the app starts.
private function init():void
{
// Set up event handlers.
fr.addEventListener(Event.SELECT, onSelect);
fr.addEventListener(Event.COMPLETE, onComplete);
}
// Called when the user clicks "Choose file..."
private function showFilePicker():void
{
fr.browse();
}
// Called when fr.browse() dispatches Event.SELECT to indicate
// that the user has picked a file.
private function onSelect(e:Event):void
{
fr.load(); // start reading the file
}
// Called when fr.load() dispatches Event.COMPLETE to indicate
// that the file has finished loading.
private function onComplete(e:Event):void
{
myImage.data = fr.data; // load the file's data into the Image
}
]]>
</fx:Script>
</s:Application>