當前位置: 首頁>>代碼示例>>PHP>>正文


PHP input::getClientOriginalName方法代碼示例

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


在下文中一共展示了input::getClientOriginalName方法的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;
}
開發者ID:rimshavbase,項目名稱:timefragment,代碼行數:33,代碼來源:functions.php


注:本文中的input::getClientOriginalName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。