Mobile safari crashing while capturing photo using

2020-07-18 11:02发布

问题:

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.