本文整理汇总了PHP中jFile::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP jFile::exists方法的具体用法?PHP jFile::exists怎么用?PHP jFile::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jFile
的用法示例。
在下文中一共展示了jFile::exists方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deletePreviewFile
public static function deletePreviewFile($id)
{
global $jlistConfig;
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$app = JFactory::getApplication();
$db = JFactory::getDBO();
// get path
$db->SetQuery("SELECT * FROM #__jdownloads_files WHERE file_id = {$id}");
$file = $db->loadObject();
if ($file->preview_filename) {
$filename = $jlistConfig['files.uploaddir'] . DS . $jlistConfig['preview.files.folder.name'] . DS . $file->preview_filename;
// check whether other downloads use also this preview file
$db->SetQuery("SELECT count(*) FROM #__jdownloads_files WHERE preview_filename = '{$file->preview_filename}'");
$result = $db->loadResult();
if (!jFile::exists($filename) || $result > 1) {
// file not exist - but we must always clear the data field
// the same when other downloads used also this file
$db->SetQuery("UPDATE #__jdownloads_files SET preview_filename = '' WHERE file_id = '{$id}'");
$db->execute();
return false;
} else {
if (jFile::delete($filename)) {
$db->SetQuery("UPDATE #__jdownloads_files SET preview_filename = '' WHERE file_id = '{$id}'");
$db->execute();
return true;
} else {
// delete error
return false;
}
}
} else {
// preview_filename field empty
return false;
}
}