How to change a a photo that has been uploaded. PHP
<p>Im very sorry if this has been answered before but I have been looking Google for a while and have not found answer. </p>

<p>My problem</p>

<p>I have uploaded a file using PHP for my site. I want to be ale to give the user the option to change the image they have uploaded. I managed to do it when they could only upload 1 image but now im trying to add more. they can add more than one photo but when it comes to changing them im having a problem. </p>

<p>here was my code for 1 image (which works)</p>

<pre><code>$newname = "$pid.jpg";
move_uploaded_file( $_FILES['fileField']['tmp_name'], "../inventory_images/$newname");
header("location: inventory_list.php"); 
exit();
</code></pre>

<p>This is the code I used to change it. </p>

<pre><code>    if ($_FILES['fileField']['tmp_name'] != "") {
    // Place image in the folder 
    $newname = "$pid.jpg";
    move_uploaded_file($_FILES['fileField']['tmp_name'], "../inventory_images/$newname");
}
header("location: inventory_list.php");
</code></pre>

<p>This is what I have now changed the code to for multiple images.</p>

<pre><code>$image1 = "$pid Image1.jpg";
$image2 = "$pid Image2.jpg";
$image3 = "$pid Image3.jpg";
$image4 = "$pid Image4.jpg";
$image5 = "$pid Image5.jpg";
move_uploaded_file( $_FILES['fileField']['tmp_name'], "../inventory_images/$image1");
move_uploaded_file( $_FILES['fileField']['tmp_name'], "../inventory_images/$image2");
move_uploaded_file( $_FILES['fileField']['tmp_name'], "../inventory_images/$image3");
move_uploaded_file( $_FILES['fileField']['tmp_name'], "../inventory_images/$image4");
move_uploaded_file( $_FILES['fileField']['tmp_name'], "../inventory_images/$image5");
header("location: inventory_list.php"); 
</code></pre>

<p>This is what I have tried but I know there is a logical error in if </p>

<pre><code>    if ($_FILES['fileField']['tmp_name'] != "") {
    // Place image in the folder 
$image1 = "$pid Image1.jpg";
$image2 = "$pid Image2.jpg";
$image3 = "$pid Image3.jpg";
$image4 = "$pid Image4.jpg";
$image5 = "$pid Image5.jpg";
move_uploaded_file( $_FILES['fileField']['tmp_name'], "../inventory_images/$image1");
move_uploaded_file( $_FILES['fileField']['tmp_name'], "../inventory_images/$image2");
move_uploaded_file( $_FILES['fileField']['tmp_name'], "../inventory_images/$image3");
move_uploaded_file( $_FILES['fileField']['tmp_name'], "../inventory_images/$image4");
move_uploaded_file( $_FILES['fileField']['tmp_name'], "../inventory_images/$image5");
}
</code></pre>

<p>And this is part of my form </p>

<pre><code>      &lt;tr&gt;
  &lt;td align="right"&gt;Product Image: 1&lt;/td&gt;
  &lt;td&gt;&lt;div class="single"&gt;
    &lt;a href="../inventory_images/&lt;?php echo $id; ?&gt; Image1.jpg" rel="lightbox" title="&lt;?php echo $product_name; ?&gt;"&gt;&lt;img src="../inventory_images/&lt;?php echo $id; ?&gt; Image1.jpg" width="142" height="188" alt="&lt;?php echo $product_name; ?&gt;" /&gt;&lt;/a&gt;
&lt;/div&gt;&lt;/td&gt; 
  &lt;/tr&gt;
        &lt;tr&gt;
    &lt;td align="right"&gt;&lt;/td&gt;
    &lt;td&gt;&lt;label&gt;
      &lt;input type="file" name="Image1" id="Image1" /&gt;
    &lt;/label&gt;&lt;/td&gt;
  &lt;/tr&gt;
</code></pre>

<p>Thanks for any help</p>
