php - Uploading a Stream of files using move_uploaded_files -
i have been trying upload stream of files using following code,
<form enctype="multipart/form-data" action="carousel_update.php?id=<?php echo $id;?>" method="post"> for($j = 1 ; $j <= $n ; $j++) { echo "<option value='$j'>$j</option>"; } echo "</td></tr> <tr><td>title:</td><td><input type=\"text\" name=\"title[$i]\"></td></tr> <tr><td>image: </td><td><input type=\"file\" name=\"picture$i\"></td></tr> <tr><td>description:</td><td><textarea name=\"description[$i]\"></textarea></td></tr> <tr><td>link text: </td><td><input type=\"text\" name=\"link_text[$i]\"></td></tr> <tr><td>link url: </td><td><input type=\"text\" name=\"link_url[$i]\"></td></tr> <tr><td>link target: </td><td><input type=\"text\" name=\"link_target[$i]\"></td></tr></table></fieldset>"; } } ?> <input type="submit" value="submit">
in action file carousel_update.php,
for($i = 1; $i<=$n ; $i++) { $file = "picture".$i; $order = $_post['order'][$i]; $title = $_post['title'][$i]; $description = $_post['description'][$i]; $linktext = $_post['link_text'][$i]; $linkurl = $_post['link_url'][$i]; $linktarget = $_post['link_target'][$i]; $target = dirname(__file__). "/images/".$_files[$file]["name"]; if(move_uploaded_file($_files[$file]["tmp_name"], $target)) { echo "uploaded"; } else { echo "problems in uploading file"; } }
if have upload 3 files, able upload images others show error. checked server logs , says:
[tue aug 20 12:00:35 2013] [error] [client 127.0.0.1] php notice: undefined index: picture2 in /var/www/akai/carousel_update.php on line 19, referer: http://127.0.0.1/akai/update_carousel.php?id=1 [tue aug 20 12:00:35 2013] [error] [client 127.0.0.1] php notice: undefined index: picture2 in /var/www/akai/carousel_update.php on line 21, referer: http://127.0.0.1/akai/update_carousel.php?id=1 [tue aug 20 12:00:35 2013] [error] [client 127.0.0.1] php notice: undefined index: picture3 in /var/www/akai/carousel_update.php on line 19, referer: http://127.0.0.1/akai/update_carousel.php?id=1 [tue aug 20 12:00:35 2013] [error] [client 127.0.0.1] php notice: undefined index: picture3 in /var/www/akai/carousel_update.php on line 21, referer: http://127.0.0.1/akai/update_carousel.php?id=1
i not know error in mu code is. in advance.
you don't have picture 2 , 3 in form, or not passed correctly php script.
well, didn't state in circumstances implementing why don't use 3 or more input file field on page?
Comments
Post a Comment