0

i have to upload a file and insert the data into tables.i am done with that part. now,i want to check whether the file has been already uploaded or not. if so,alert should be thrown.

 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"; } } } } 
5
  • It is not clear what your actual problem is. Please elaborate. Commented Aug 1, 2017 at 5:22
  • @yakobom i sholud not upload the file which is already been uploaded. Commented Aug 1, 2017 at 5:25
  • are you encrypting a name while uploding? @dodo Commented Aug 1, 2017 at 7:11
  • @ankitsuthar no am just want to check if the file's records has already been inserted into the database or not Commented Aug 1, 2017 at 7:16
  • see this so question may be it helps Commented Aug 1, 2017 at 7:39

1 Answer 1

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{ } 
Sign up to request clarification or add additional context in comments.

1 Comment

i did add a column filename to the table where the records being uploaded.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.