• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to check if the file is already uploaded into database

       $filename = explode(".", $_FILES['file']['name']);
       foreach($a as $b){
                           echo"file already uploaded";
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.

While storing the file in the database, you'd have some sort of identifier that you store with it, such as a sha1 or md5 of the file contents. You'd then check if your new file upload's identifier is the same as one already in the database.

Why upload to the database? This is generally a bad idea. It's better to store a reference to the file, and just store the file on the filesystem. When I do uploads:

1) Store the absolute path to the file.
2) Store the original filename.
3) Store who uploaded it.
4) Store the date it was uploaded.
5( Store the file mime type

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.