Upload Picture Form Fails On Mobile Chrome

拟墨画扇 提交于 2019-12-10 17:16:08

问题


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 check 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());


来源:https://stackoverflow.com/questions/26745291/upload-picture-form-fails-on-mobile-chrome

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