我必须上传一个文件并将数据插入tables.i我已完成该部分。 现在,我想检查文件是否已经上传。如果是这样,应该抛出警报。
if(isset($_POST["submit"]))
{
if($_FILES['file']['name'])
{
$filename = explode(".", $_FILES['file']['name']);
$a=$filename[0];
foreach($a as $b){
if($b==$filename[0]){
echo"file already uploaded";
}
}
}
}
答案 0 :(得分:0)
if($filename[1] == 'csv')
{
$fp = fopen($_FILES['file']['tmp_name'],'r') or die("can't open file");
$a=$filename[0];
echo $a;
$query1 = $this->db->query("SELECT * from table WHERE table.filename='".$a."'");
$b=$query1->num_rows();
if($b>0)
{
echo "<script type='text/javascript'>alert('FILE ALREADY BEEN UPLOADED')</script>";
}
else{
}