本文整理匯總了PHP中input::getRealPath方法的典型用法代碼示例。如果您正苦於以下問題:PHP input::getRealPath方法的具體用法?PHP input::getRealPath怎麽用?PHP input::getRealPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類input
的用法示例。
在下文中一共展示了input::getRealPath方法的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;
}