0

Input type file doesn't work with android 4.4 (kitkat).

Is there a way to use form submit with input type="file" with phonegap in android 4.4. My form looks like:

<form id="testFrm" method="POST" enctype="multipart/form-data" >
    <input type="text" id="sub" name="subject" placeholder="Subject" />
    <input type="text" id="desc" name="desc" placeholder="Description" />
    <input type="file" name="file" id="file" />
    <input type="submit" />
</form>

I'm on cordova 2.8

Sana
  • 319
  • 1
  • 3
  • 18
  • Here is a solution that should work for you. It appears that input type of "file" has limited support in PhoneGap: http://stackoverflow.com/questions/13861310/how-to-upload-file-with-phonegap-and-jquerymobile/13862151#13862151 – Max Worg Jan 20 '15 at 13:23
  • http://stackoverflow.com/questions/19882331/html-file-input-in-android-webview-android-4-4-kitkat/19962450#19962450 – jcesarmobile Jan 20 '15 at 13:40

1 Answers1

1

Seems you want to use the PhoneGap FileTransfer method which according to the docs "The FileTransfer object allows you to upload or download files to and from a server." which is exactly what you need. There is a code example there that should get you started.

UPDATE (by request from your comment):

One form is not really designed to "include" another form however any of the fields that are included inside the "form" tag will be transmitted with the submit to the server (in the form of "Name1=value1&Name2=value2&",etc) so instead of having two forms you can just have multiple fields under one form tag.

Max Worg
  • 2,932
  • 2
  • 20
  • 35
  • How can I send other form (title and description text) data along with file data on form submit. Can you please guide in detail ? – Sana Jan 21 '15 at 12:43