本文整理匯總了PHP中Basic::AddLastSlash方法的典型用法代碼示例。如果您正苦於以下問題:PHP Basic::AddLastSlash方法的具體用法?PHP Basic::AddLastSlash怎麽用?PHP Basic::AddLastSlash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Basic
的用法示例。
在下文中一共展示了Basic::AddLastSlash方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: saveFile
/**
* save file to $dirname and return filename as stored on ftp
*
* @param string
* @param HttpUploadedFile
* @param string filename with suffix (usually id from DB)
* @param bool overwrite older file with given $filename ?
* @return string
*/
public static function saveFile($dirname, $file, $filename = NULL, $overwriteOldFile = true)
{
// return if no file given [may occur only when editing item otherwise it's controlled when submitting form]
if (!$file instanceof HttpUploadedFile or empty($file->name)) {
return null;
}
$dirname = Basic::AddLastSlash($dirname);
Basic::mkdir($dirname);
if (is_null($filename)) {
$filename = $file->name;
}
$filename = self::handleFilename($filename);
if (!$overwriteOldFile) {
$filename = self::getUniqueFilename($dirname, null, $filename);
}
$dest = $dirname . $filename;
$file->move($dest);
return $filename;
}