alex alex - 1 year ago 183
PHP Question

Laravel: check file existence without extension

I'm saving files in server only with a md5 hashed name without extension.
I noticed laravel

method will return true even if file does not exists. in fact laravel assume file name as a directory name. is there any way to force laravel to check file existence ?

Answer Source

Actually, it's because the way PHPs file_exists function works. Anyways, you may use something like this:

if(is_file('68e109f0f40ca72a15e05cc22786f8e6')) {
    // ...

Also, you may try glob like this:

$all = glob('*'); // Read everything from current directory in array
if(in_array('68e109f0f40ca72a15e05cc22786f8e6', $all)) {
    // ...

There are more ways to do this but why not use an extension?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download