Upload Picture Form Fails On Mobile Chrome

2019-06-24 08:37发布

问题:

I'm building a mobile webapp, in which pictures from the user's phone play a significant part.

I've got this form, in which a user can upload a picture taken from his mobile phone into the app's DB. I'm using CodeIgniter's upload class in order to do the actual uploading.

<form enctype="multipart/form-data" action="myapp/do_upload" method="post" accept-charset="utf-8">
            <input type="file" accept="image/*" capture="camera" name="userfile"></input>
            <input type="submit" value="Submit" class="btn btn-block"></button>
    </form>

PROBLEM:

The app works great on my desktop computer: You choose a file, it uploads it, and throws an error if it doesn't work.

However, when trying to do the same thing on my mobile phone (Android running Mobile Chrome), the submit button refuses to work.

I've tried fiddling with the attributes - no success.

Any Idea what's stopping the form from actually working?

回答1:

You Problem is here

<form enctype="multipart/form-data" action="myapp/do_upload" method="post" accept-charset="utf-8">
            <input type="file" accept="image/*" capture="camera" name="userfile"></input>
            <input type="submit" value="Submit" class="btn btn-block"></button> //wrong
            <button type="submit" value="Submit" class="btn btn-block"></button> //right
    </form>


回答2:

Did you checked if the filetype that you are trying to upload via mobile is in allowed_types?

If you did, can you please post what you get from:

var_dump($this->upload->data());