hello guys how are you i wrote this code but i have an proplem i can not verify if there is no file uploaded when anyone hit submit and i can not specific the allowed extinsion for example "jpg" how can i do this in "foreach", i can do this when i upload just one image but this code for multi upload and if have you noticed i have used array in the form.
<?php
mysql_connect('localhost','root','root')or die (mysql_error());
mysql_select_db('storeimage');
?>
<?
if ($_POST['submit'] ){
$file=$_FILES['file'];
$name=$_FILES['file']['name'];
$tmp_name=$_FILES['file']['tmp_name'];
foreach($name as $key=>$value){
$name_file=$name[$key];
$tmp_file=$tmp_name[$key];
$imgpath = rand().'.jpeg';
move_uploaded_file($tmp_file,'images/'.$imgpath);
$insert=mysql_query("insert into imagelocation values('','images/$imgpath')")or die (mysql_error());
$id=mysql_insert_id();
$select=mysql_query("select * from imagelocation where id='$id' ");
while ($row=mysql_fetch_object($select)){
echo "<center><img src='$row->images'/></center><br/>";
}
}
}
?>
<form action='' method='post' enctype='multipart/form-data'>
<input type='file' name='file[]' multiple />
<input type='submit' name='submit'/>
</form>