4

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?

Meneer Venus
  • 1,039
  • 2
  • 12
  • 28
Tom Granot
  • 1,840
  • 4
  • 22
  • 52

2 Answers2

3

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>
Murtaza Khursheed Hussain
  • 15,176
  • 7
  • 58
  • 83
1

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());
Gabriel Moretti
  • 676
  • 8
  • 23
  • I did indeed. I'm trying to upload a jpg file and jpg is listed in `allowd_types`. – Tom Granot Nov 06 '14 at 11:52
  • can you please post what you get from $this->upload->data()? You will get an array with some info, one of those is a "file_type" string. This way, you can see what type your server is receiving. Then, check if this type is in your mimes.php (in config folder). – Gabriel Moretti Nov 07 '14 at 05:13
  • Problem is - the form won't submit at all! It never gets to the actual upload script, but rather gets stuck on the form itself. The PHP function that handles the upload is never called - the submit button won't send me anywhere if a a file has been loaded into it. – Tom Granot Nov 07 '14 at 08:31
  • That's really weird.. Are you using RewriteEngine to remove the file extension of the URL?? If you dont, try to put .php in your form action. – Gabriel Moretti Nov 08 '14 at 12:03
  • I'm uding codeigniter, and do_upload is. Method inside the money controller. How's adding .php gonna help here? – Tom Granot Nov 08 '14 at 17:46
  • oh,my bad.. Im sorry. did you checked your routes file? can you access this method directly? – Gabriel Moretti Nov 09 '14 at 02:26
  • Sute can, either via adress bar or link – Tom Granot Nov 09 '14 at 03:29
  • 1
    Sorry, but I think I cant help you.. You should start a bounty, I cant say if it's a problem with your server. – Gabriel Moretti Nov 10 '14 at 02:37
  • Maybe this can help you http://stackoverflow.com/questions/2935946/sending-images-using-http-post/2937140#2937140 – Florin Nov 15 '14 at 12:38