i am trying to use file upload in while loop but i can upload a file for the first record of the list, i cannot upload for other records. whenever i trying to upload for a second record or any other record of the list its showing me please select a file alert which i have put for blank file.it allow me upload for the first record only. how can i solve it?
thanks in advance.
below files i have used.
<?php
$select="select * from tbl_post_artical where writername='".$_SESSION["writer_id"]."' order by id desc;";
$query=mysql_query($select) or die($select);
while($row=mysql_fetch_array($query))
{
?>
<td align="center" >
<?php if($row['action']!='approved')
{
echo '<input type="file" name="fileToUpload" id="fileToUpload" value='.$row['id'].' />
<img src="images/fileupload.png" onclick="savepic('.$row['id'].')" title="UPLOAD"/>';
}
else
{
echo $str='<font color="green">DONE</font>';
} ?>
<?php } ?>
**doajaxfileupload.php**
<?php
session_start();
if($_SESSION["writer"]=='') print('<script>window.location.href="login.php"</script>');
include('conn.php');
include('function/fun.php');
$id=$_REQUEST['id'];
$ImageName = $_FILES['fileToUpload'][name];
$fileElementName = 'fileToUpload';
if(empty($_FILES['fileToUpload']['tmp_name']) || $_FILES['fileToUpload']['tmp_name'] == 'none')
{
echo '<script>alert("Select File")</script>';
}
else
{
$path = 'file/';
$location = $path . $_FILES['fileToUpload']['name'];
move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $location);
$s="update tbl_post_artical set
file_name='$ImageName',
upload_date='".date('m/d/y')."'
where id='".$id."' and writername='".$_SESSION["writer_id"]."'";
$result=mysql_query($s) or die($s);
echo '<script>alert("File Uploaded Successfully")</script>';
die("<script>window.location.href='writer_my_job.php'</script>");
}
?>