本文整理汇总了PHP中input::guessClientExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP input::guessClientExtension方法的具体用法?PHP input::guessClientExtension怎么用?PHP input::guessClientExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类input
的用法示例。
在下文中一共展示了input::guessClientExtension方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadImagesProcess
/**
* Upload Proccess Function
* @param input $file Get upload file
* @param string $destinationPath Set destination path
* @param digit $destinationWidth Set destination image width
* @param digit $destinationHeight Set destination image height
* @param digit $destinationRetinaWidth Set destination retina image width
* @param digit $destinationRetinaHeight Set destination retina image height
* @param string $thumbnailsPath Set thumbnails path
* @param digit $thumbnailsWidth Set thumbnails image width
* @param digit $thumbnailsHeight Set thumbnails image height
* @param digit $thumbnailsRetinaWidth Set thumbnails retina width
* @param digit $thumbnailsRetinaHeight Set thumbnails retina height
* @return string $normal_name Return uploaded file name
*/
function uploadImagesProcess($file, $destinationPath, $destinationWidth, $destinationHeight, $destinationRetinaWidth, $destinationRetinaHeight, $thumbnailsPath, $thumbnailsWidth, $thumbnailsHeight, $thumbnailsRetinaWidth, $thumbnailsRetinaHeight)
{
$ext = $file->guessClientExtension();
// Get real extension according to mime type
$fullname = $file->getClientOriginalName();
// Client file name, including the extension of the client
$hashname = date('H.i.s') . '-' . md5($fullname);
// Hash processed file name, including the real extension
$normal_name = $hashname . '.' . $ext;
$retina_name = $hashname . '@2x.' . $ext;
$picture = Image::make($file->getRealPath());
// crop the best fitting ratio and resize image
$picture->fit($destinationWidth, $destinationHeight)->save(public_path($destinationPath . $normal_name));
$picture->fit($destinationRetinaWidth, $destinationRetinaHeight)->save(public_path($destinationPath . $retina_name));
$picture->fit($thumbnailsWidth, $thumbnailsHeight)->save(public_path($thumbnailsPath . $normal_name));
$picture->fit($thumbnailsRetinaWidth, $thumbnailsRetinaHeight)->save(public_path($thumbnailsPath . $retina_name));
return $normal_name;
}