gabrielkolbe Posted July 31, 2007 Share Posted July 31, 2007 I have this problem, I don't think it is to difficult, but I can't get my mind arround it... I have an array with a list of image name in it.. (the images are on the server) This images are displayed in a foreach loop, on a page with a option to update the image, BUT the names of the image on the server must stay the same...below is the code as I have written it up to know, it does not work it only updates (maybe the last image in the array) <? $images = array (1 => 'about us', 'recruitment', 'training'); if($_POST['posttoimage'] =="edit_images"){ unlink("pics/banners/".$_POST['imagename'].".gif"); $uploadfile="pics/banners/".$_POST['imagename'].".gif"; if ((move_uploaded_file($_FILES["image"]["tmp_name"], $uploadfile))or die("Couldn't copy the file!".$_FILES["image"]["tmp_name"])){ } } ?> <form name="form1" enctype="multipart/form-data" method="POST"> <input type="hidden" name="posttoimage" value="edit_images"> <table width="100%" border="0" cellspacing="0" cellpadding="0" bordercolor="#0033FF"> <? $i==0; foreach ($images as $image) { $i++; ?> <tr> <td height="30" align="left"> Edit <?=ucfirst($image)?> page image<br> <input name="image<?=$i?>" type="file" size="30" > <input name="imagename" type="hidden" value="<?=$image?>"> </td> </tr> <tr align="left"> <td height="30" > <img src="pics/banners/<?=$image?>.gif" height="100" width="387"></td> </tr> <tr> <? } ?> <td height="30" align="right"><input name="Submit" type="submit" class="menu_names" value="Submit"></td> </tr> </table></td> </tr> </table> </form> Link to comment https://forums.phpfreaks.com/topic/62646-updating-images-but-names-come-from-array/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.