php check if file exist

后端 未结 2 949
梦谈多话
梦谈多话 2020-12-21 04:33

can someone guide me on how to do checking to tell if file already exist in database or not before we upload it?

i wanna upload a file into database, but before it s

2条回答
  •  感动是毒
    2020-12-21 04:58

    I'm not sure if this is what you're asking, but have you used PHP's built in function, file_exists(ABSOLUTE-PATH-TO-FILE)?

    $exists = file_exists('myfile.doc');
    if(!$exists) {
    // do your processing
    }
    

    http://php.net/manual/en/function.file-exists.php

    If you're checking the database, then just query whatever column might hold your file, for example:

    SELECT * FROM my-table WHERE my-column = 'my-uploaded-file-name';
    

提交回复
热议问题