Andy Eは、これを行うためのHTMLベースの方法がないことは正しいです*。ただし、Flashを使用する場合は、使用できます。以下は、Flashがインストールされているシステムで確実に機能します。アプリがiPhoneで動作する必要がある場合は、もちろん、フォールバックHTMLベースのソリューションが必要になります。
*(2013年4月22日更新: HTMLはHTML5でこれをサポートするようになりました。他の回答を参照してください。)
Flashアップロードには、他にも利点があります。Flashを使用すると、大きなファイルのアップロードが進行するときに進行状況バーを表示できます。(私はそれについて間違っているかもしれませんが、舞台裏でFlashを使用することにより、Gmailがそれを行う方法であると確信しています。)
これは、ユーザーがファイルを選択して表示できるFlex4アプリのサンプルです。
<?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>