html - Safari里表单input怎么上传音频文件?
高洛峰
高洛峰 2017-04-18 09:34:11
0
3
1537


表单里用<input type="file">,iphone手机Safari浏览器中,点击上传文件只有这几个选项,怎么样可以添加“本地选择器”或者“音频选择”这样的选项?我只想可以上传音频,请各路大神拯救。

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(3)
大家讲道理

Hmm, no solution. Users can only select files from the photo album. If they can select audio files, where can they select audio files? ring? joke. recording? Native apps don’t have this permission.

If you must have this function, you can allow users to upload videos and then extract the audio in the background

--- update:

In fact, this is not very troublesome. The videos uploaded by users are not very large, and two or three servers can handle it. If this function is used sparingly, one server will suffice. Of course, you can also use a CDN to save trouble. Most of today’s CDNs provide media conversion processing, and you just need to pay a little money.

For Android machines, you can also use Java or Flash front-end to extract audio.

In addition, there is a second method that is to upload a video, but only the audio is played in the first part, so that the user cannot see the video content. However, in addition to the file that the user wants to download may be relatively large, it will also involve privacy.

So, if this function is dispensable to you, then give up this idea as soon as possible. If this function is necessary, it is recommended to use a CDN, or build your own server and use ffmpeg to specifically handle this.

This approach is actually very common in social applications of a slightly larger scale. Our company did something similar in 2009, where we wanted to play the speex audio recorded by client users on computer web pages and mobile web pages. I researched it for several days. , tried several solutions, and finally used the server to transfer. Twitter also converts GIFs uploaded by users into video files. In the modern web, converting a video on the server side is the same as processing images uploaded by users.

--- update:

Another solution is to allow users to record and upload audio in WeChat. WeChat's JS SDK has related interfaces. I just don’t know if it matches your product needs.

小葫芦

The answer is no, Safari does not have such an API

Peter_Zhu

Some Android machines can do this, you can try it on iOS.
<input type="file" accept="audio/*">

accept is a standard HTML5 attribute.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!