本文整理匯總了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;
}
}