Welcome Guest, Not a member yet? Register   Sign In
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.

(This post was last modified: 08-01-2017, 07:54 AM by skunkbad.)

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

Theme © iAndrew 2016 - Forum software by © MyBB