3

I'm have a little form which allows file upload using PHP. The form works well using Mac, Windows and iOS, but I'm having problems with Android:

  • If I select a picture from the phone and upload it >> works.
  • If I select "camera", take the picture and send it, the file somehow gets lost. Same if I take the picture first and upload it afterwards. I tried this with 2 different Android phones, same problem.

print_r($_FILES) results in:

Array (
    [Photo] => Array (
        [name] => 14670896179861993968797.jpg
        [type] =>
        [tmp_name] =>
        [error] => 1
        [size] => 0
    )
)

My PHP code [ftp login details hidden using "XXX"]:

$file = $_FILES["Photo"]["name"];
$file_ext = substr( $file, strrpos( $file, '.' )+1 );
$tmp_file = $_FILES["Photo"]["tmp_name"];
$folder = "public_html/itcma/slips/";

$conn_id = ftp_connect("XXX");
$login_result = ftp_login($conn_id, "XXX", "XXX");
ftp_put($conn_id, $folder.$file, $tmp_file , FTP_BINARY);
ftp_rename ($conn_id, $folder.$file, $folder.$_GET["id"].".".$file_ext);
ftp_close($conn_id);

My form [shortened]:

<form action="" method="post" enctype="multipart/form-data" name="upload" id="upload">
<input class="form-control" type="file" name="Photo"></input>
<input type="submit" name="submit" id="submit" value="Upload payment slip"/>
</form>

Any idea why it works in most cases, but NOT if uploading directly from camera? I tried accept="image/" capture="camera"* inside the file input already, which opens directly the camera. Same problem.

Thanks so much in advance!

miken32
  • 42,008
  • 16
  • 111
  • 154
Steve Pony
  • 63
  • 6
  • P.S.: "File gets lost" means that no file gets uploaded. If I echo $tmp_file there is no value as well. – Steve Pony Jun 28 '16 at 05:15
  • Versions? This is a good read: http://stackoverflow.com/questions/21523544/html-file-input-control-with-capture-and-accept-attributes-works-wrong Specs have changed some over last years. – ficuscr Mar 23 '17 at 21:31

0 Answers0