1

I have been trying to upload multiple image in php with this code. I want need is that can select multiple image in php but it can't work in mobile website.

<input type="file" name="img_logo1[]" id="img_logo1" multiple />

sorry for bad english... :)

Gautam Golakiya
  • 453
  • 2
  • 12

1 Answers1

2

That HTML should work, with a couple of proviso's

  • You have to select all the files in one go i.e. not using more than one click of the browse button. Each new click on the browse button will replace the previous list of files selected.

  • You have to have an enctype="multipart/form-data" on your <form> tag.

This simple example works

<?php
if($_SERVER["REQUEST_METHOD"] == 'POST') {
    echo '<pre>POST ARRAY' . print_r($_POST) . '</pre>';
    echo '<pre>FILES ARRAY' . print_r($_FILES) . '</pre>';
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
    <form method="post" enctype="multipart/form-data">
        <input type="file" name="img_logo1[]" id="img_logo1" accept="image/*" multiple />
        <button type="submit" name="logout">Go</button>
    </form>
</body>
</html>

And produces this output

POST ARRAY Array
(
    [logout] => 
)

FILES ARRAY Array
(
    [img_logo1] => Array
        (
            [name] => Array
                (
                    [0] => avatar1.png
                    [1] => avatar100x100.png
                )
            [type] => Array
                (
                    [0] => image/png
                    [1] => image/png
                )
            [tmp_name] => Array
                (
                    [0] => D:\wamp\tmp\phpF7E6.tmp
                    [1] => D:\wamp\tmp\phpF7F7.tmp
                )
            [error] => Array
                (
                    [0] => 0
                    [1] => 0
                )
            [size] => Array
                (
                    [0] => 7666
                    [1] => 4152
                )
        )
)
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • hi riggs i am already use this code and it's perfectly work on my system browser but when i am open the url in my mobile browser it can't help for select multiple image. – Gautam Golakiya Jan 22 '16 at 06:54
  • Maybe this post will explain your mobile browser issues http://stackoverflow.com/a/33176317/2310830 – RiggsFolly Jan 22 '16 at 09:35