本文整理汇总了PHP中dmOs::sanitizeFileName方法的典型用法代码示例。如果您正苦于以下问题:PHP dmOs::sanitizeFileName方法的具体用法?PHP dmOs::sanitizeFileName怎么用?PHP dmOs::sanitizeFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dmOs
的用法示例。
在下文中一共展示了dmOs::sanitizeFileName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createMediaFromUploadedFile
protected function createMediaFromUploadedFile(array &$values)
{
$file = $values['file'];
$folder = dmDb::table('DmMediaFolder')->findOneByRelPathOrCreate('widget');
$media = dmDb::table('DmMedia')->findOneByFileAndDmMediaFolderId(dmOs::sanitizeFileName($file->getOriginalName()), $folder->id);
if (!$media) {
$media = dmDb::create('DmMedia', array('dm_media_folder_id' => $folder->id))->create($file)->saveGet();
}
$values['mediaId'] = $media->id;
}
示例2: execute
public function execute(Doctrine_Connection $connection, $arguments = array(), $options = array())
{
$adapter = $this->getAdapter($connection);
$infos = $adapter->getInfos();
$infos['tag'] = dmString::underscore(dmOs::sanitizeFileName($options['tag']));
$file = $this->getFile($infos);
$this->log(sprintf('About to backup %s@%s to %s', $infos['name'], $infos['host'], $file));
$this->createDir();
$adapter->execute($file);
$this->log('Done.');
}
示例3: clearName
public function clearName($validator, $values)
{
if (!empty($values['file'])) {
$filename = dmOs::sanitizeFileName($values['file']->getOriginalName());
if (empty($filename)) {
$error = new sfValidatorError($validator, 'This is a bad name');
// throw an error bound to the password field
throw new sfValidatorErrorSchema($validator, array('file' => $error));
}
}
return $values;
}
示例4: isValidFilenameAndExtension
/**
* Used by ->clearnName() to validate filename.
* @param string $filename
*/
public function isValidFilenameAndExtension($filename)
{
$filenameAndExt = explode('.', dmOs::sanitizeFileName($filename));
if (count($filenameAndExt) < 2) {
return false;
}
return true;
}
示例5: create
/**
* Physically creates asset
*
* @param string $asset_path path to the asset original file
* @param bool $move do move or just copy ?
*/
public function create(sfValidatedFile $file)
{
$this->file = $this->getAvailableFileName(dmOs::sanitizeFileName($file->getOriginalName()));
$this->clearCache();
$file->save($this->getFullPath());
$this->refreshFromFile();
return $this;
}
示例6: sanitizeFile
/**
* Sanitize files name (moves file if non regular name)
*/
protected function sanitizeFile($file)
{
if (basename($file) != dmOs::sanitizeFileName(basename($file))) {
$renamedFile = dmOs::join(dirname($file), dmOs::sanitizeFileName(basename($file)));
while (file_exists($renamedFile)) {
$renamedFile = dmOs::randomizeFileName($renamedFile);
}
rename($file, $renamedFile);
$file = $renamedFile;
}
return $file;
}