简体   繁体   中英

Upload audio files from html5 web application in Safari iPad

Im building a web application that must run in iPad. The problem i have is that i give the user the posibility to upload videos, images and audio. The two first ones i make them like this:

<input type="file" accept="video/*">
<input type="file" accept="image/*">

And both work perfect. But when i do:

<input type="file" accept="audio/*">

Its like ignores the "accept" parameter in iPad devices. And when i use that input the device only lets me choose photo or video. Any suggestions?

If the elegant way does not work, you may try the more verbose one. According to this page , you should be able to define a list of accepted file extensions:

<input type="file" accept=".wav,.aif,.aiff,.flac,.alac,.aac,.ogg,.mp3">

I did not test it and I don't know if it's case sensitive, but you could give it a try, and adapt the list to your need.

I had the same problem right now and I think I could solve it by using this code:

<input type="file" accept="audio/mp3, audio/wav">

MacOS as well as iOS seem to acknowledge the accept values.

Here is a link to all supported media types: Apple Safari Web Content Guide - Use Supported iOS Rich Media MIME Types

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM