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


PHP UploadedFile::createFromGlobals方法代碼示例

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


在下文中一共展示了UploadedFile::createFromGlobals方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createFromGlobals

 /**
  * Instantiate request from php _SERVER variable
  * @param array server
  */
 public static function createFromGlobals()
 {
     $server = $_SERVER;
     $uriParts = parse_url($server['REQUEST_URI']);
     $uriParts['host'] = $server['SERVER_NAME'];
     $uriParts['port'] = $server['SERVER_PORT'];
     $uriParts['scheme'] = isset($server['REQUEST_SCHEME']) ? $server['REQUEST_SCHEME'] : (isset($server['HTTPS']) && $server['HTTPS'] == 'on' ? 'https' : 'http');
     if (function_exists('getallheaders')) {
         // a correct case already
         $apacheHeaders = getallheaders();
         foreach ($apacheHeaders as $header => $value) {
             $headers[$header] = array_map('trim', explode(',', $value));
         }
     } else {
         $headers = array();
         // normalize the header key
         foreach ($server as $key => $value) {
             if (substr($key, 0, 5) != 'HTTP_') {
                 continue;
             }
             $name = str_replace(' ', '-', ucwords(str_replace('_', ' ', strtolower(substr($key, 5)))));
             $headers[$name] = array_map('trim', explode(',', $value));
         }
     }
     $request = new static($server['REQUEST_METHOD'], new Uri($uriParts), $headers, Stream::createFromContents(file_get_contents('php://input')), $server, $_COOKIE, UploadedFile::createFromGlobals($_FILES));
     if ($server['REQUEST_METHOD'] == 'POST' && in_array($request->getMediaType(), array('application/x-www-form-urlencoded', 'multipart/form-data'))) {
         $request->setParsedBody($_POST);
     }
     return $request;
 }
開發者ID:rosengate,項目名稱:exedra,代碼行數:34,代碼來源:ServerRequest.php


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