Skip to Content
MOBILE WEB程式設計--第二版
book

MOBILE WEB程式設計--第二版

by Maximiliano Firtman
December 2013
Intermediate to advanced
752 pages
16h
Chinese
GoTop Information, Inc.
Content preview from MOBILE WEB程式設計--第二版
242
|
第八章
檔案選取欄位
瀏覽器通常會使用檔案選擇控制項來將本機檔案傳送給伺服器。當使用者選擇這個控制
項,會出現一個彈出視窗,讓他可以從公共內部記憶體資料夾或是外接記憶卡中選擇一
個檔案。以下是一個簡單的上傳表單:
<label for="photo">Upload a photo</label>
<input type="file" name="photo">
HTML5
<input type="file">
元素中加入兩個屬性:用來選擇多個檔案的
multiple
林屬性,以及過濾檔案類型的
accept
屬性,我們可以選擇:
只要圖像:
image/*
只要影片:
video/*
只要音訊:
audio/*
任何特定的格式(MIME 類型)。
一串以逗號分隔的 MIME 類型。
我們來看一些範例:
<label for="manyfiles">Upload multiple files </label>
<input type="file" name="manyfiles" multiple>
<label for="video">Upload only a video</label>
<input type="file" name="video" accept="video/*">
有一些行動瀏覽器,如 Android 2.1 之前的版本,以及 iOS Safari 5.1 之前的版本,都無
法上傳任何類型的檔案。因此,當你使用檔案上傳選取器時,螢幕會顯示停用的樣式,
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

成為卓越程式設計師的38項必修法則

成為卓越程式設計師的38項必修法則

Pete Goodliffe
精實企業|高績效組織如何達成創新規模化

精實企業|高績效組織如何達成創新規模化

Jez Humble, Joanne Molesky, Barry O'Reilly

Publisher Resources

ISBN: 9789862769522