Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Your for loop need to be modified. Array indexes starts from 0. And the last element should be Array length - 1; Your for loop need to be modified as bellow code sample.</p> </blockquote> <p>Actually, it's looping through several $_POST itens. His HTML probably has something like:</p> <pre><code>&lt;input type="file" name="pac_img_1"&gt; &lt;input type="file" name="pac_img_2"&gt; &lt;input type="file" name="pac_img_3"&gt; </code></pre> <p>and he is trying to get these images.</p> <p>I would do this differently.</p> <p>HTML:</p> <pre><code>&lt;input type="file" name="pac_img[]" /&gt; &lt;input type="file" name="pac_img[]" /&gt; &lt;input type="file" name="pac_img[]" /&gt; </code></pre> <p>(note that you can dynamically add file inputs without worrying about names)</p> <p>PHP:</p> <pre><code>if (count($_FILES['pac_img']) &gt; 0){ echo("You have uploaded the following images:-&lt;ul&gt;"); foreach($_FILES['pac_img'] as $key =&gt; $file){ $target_path = "files/" . $companyName . "/images/"; $target_path = $target_path . basename( $file['name']); if(move_uploaded_file($file['tmp_name'], $target_path)) { echo "&lt;li&gt;&lt;a href='". $target_path . "'&gt;". basename( $file['name'] ). "&lt;/a&gt;&lt;/li&gt;"; } else{ echo "There was an error uploading an image"; } } echo("&lt;/ul&gt;"); }else{ echo("None uploaded"); } </code></pre> <p>And last, but not least: ALWAYS check if uploaded files are what they suposed to be. (<a href="http://www.acunetix.com/websitesecurity/upload-forms-threat.htm" rel="nofollow">http://www.acunetix.com/websitesecurity/upload-forms-threat.htm</a>)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload