Mobile safari crashing while capturing photo using input type = file

别说谁变了你拦得住时间么 提交于 2019-12-06 07:21:50

问题


I am using input type file for launching the camera in iOS . The following line of code I am using :

 <input type="file" name="select a Picture"/>

When I press the button it shows two option i.e. 1) Take a Picture 2. Choose from the gallery If I select option Choose from the gallery then it launches the native gallery when I select the picture from the gallery then I can see it in the preview , so choose from gallery is working fine .

But the problem is with taking picture using camera . When I Press the take picture it launches the camera but it after capturing the photo it directly goes back to the safari . And there is pop of which shows the following error:

A problem occurred with this webpage so it was reloaded 

so how to overcome this issue ?


回答1:


In my case, adding a name="" attribute fixed the problem. I had:

<input id="uploadPhotoInput" type="file" capture="camera" accept="image/*">

and it crashed every time. Changing it to:

<input id="uploadPhotoInput" name="uploadPhotoInput" type="file" capture="camera" accept="image/*">

seems to have done the trick. I have no idea why, since I wasn't submitting it in a form or anything, but there it is.




回答2:


Try the following:

<input type="file" accept="image/*" capture="camera">

Also remove any onchange="xxxxxxx" from your input tag (if you have any) since for some reason is causing problems in iOS8.



来源:https://stackoverflow.com/questions/29225824/mobile-safari-crashing-while-capturing-photo-using-input-type-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!