Welcome Guest, Not a member yet? Register   Sign In
Storing an image in a database/table field
#5

[eluser]Evil Wizard[/eluser]
the unlink will generate php warnings and notices if the file/path supplied to it doesn't exist or the permissions are wrong.
Code:
function deleteFile($strFile)
{
    $blSuccess = FALSE;
    clearstatcache();
    if (is_readable($strFile) && !is_dir($strFile)) {
        if(@unlink($strFile)) {
            $blSuccess = TRUE;
        }
    }
    return $blSuccess;
}
When you use the is_dir() and is_readable() functions the results are cached for faster future use which is why I use the clearstatcach(0 function to ensure that the checks are current. Prefixing the unlink() function call with "@" suppresses the warnings and notices should any be generated.


Messages In This Thread
Storing an image in a database/table field - by El Forum - 05-28-2009, 06:22 PM
Storing an image in a database/table field - by El Forum - 05-28-2009, 07:11 PM
Storing an image in a database/table field - by El Forum - 05-28-2009, 08:39 PM
Storing an image in a database/table field - by El Forum - 05-29-2009, 02:55 AM
Storing an image in a database/table field - by El Forum - 05-29-2009, 04:56 AM
Storing an image in a database/table field - by El Forum - 05-30-2009, 04:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB