本文整理匯總了PHP中file::guessExtension方法的典型用法代碼示例。如果您正苦於以下問題:PHP file::guessExtension方法的具體用法?PHP file::guessExtension怎麽用?PHP file::guessExtension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類file
的用法示例。
在下文中一共展示了file::guessExtension方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: preUpload
/**
* @ORM\PrePersist
*/
public function preUpload()
{
if (null !== $this->file) {
// do whatever you want to generate a unique name
$this->photo = uniqid() . '.' . $this->file->guessExtension();
}
}
示例2: preUpload
/**
* @ORM\PrePersist
*/
public function preUpload()
{
if (null !== $this->file) {
// do whatever you want to generate a unique name
$this->picture_name = $this->file->getClientOriginalName();
$this->picture = $this->username . '.' . $this->file->guessExtension();
}
}
示例3: preUploadFile2
/**
* @ORM\PrePersist
*/
public function preUploadFile2()
{
if (null !== $this->file2) {
// do whatever you want to generate a unique name
$this->second_fichier_nom = $this->file2->getClientOriginalName();
$this->second_fichier = uniqid() . '.' . $this->file2->guessExtension();
}
}
示例4: upload
public function upload()
{
// var_dump(pathinfo($this->file, PATHINFO_EXTENSION));die();
if (null === $this->file) {
return false;
} else {
$this->path = sha1(uniqid(mt_rand(), true)) . '.' . $this->file->guessExtension();
}
$this->file->move($this->getUploadRootDir(), $this->path);
unset($this->file);
return true;
}
示例5: preUpload
/**
* @ORM\PrePersist()
* @ORM\PreUpdate()
*/
public function preUpload()
{
if (null !== $this->file) {
// faites ce que vous voulez pour générer un nom unique
$this->photo = sha1(uniqid(mt_rand(), true)) . '.' . $this->file->guessExtension();
}
}