PHP 5는 지원이 종료되었으며 2026년 1월 31일에 지원 중단됩니다. 지원 중단 후에는 조직에서 이전에 조직 정책을 사용하여 레거시 런타임의 배포를 다시 사용 설정한 경우에도 PHP 5 애플리케이션을 배포할 수 없습니다. 기존 PHP 5 애플리케이션은 지원 중단 날짜 이후에도 계속 실행되고 트래픽을 수신합니다. 지원되는 최신 PHP 버전으로 마이그레이션하는 것이 좋습니다.
REGION_ID는 앱을 만들 때 선택한 리전을 기준으로 Google에서 할당하는 축약된 코드입니다. 일부 리전 ID는 일반적으로 사용되는 국가 및 주/도 코드와 비슷하게 표시될 수 있지만 코드는 국가 또는 주/도와 일치하지 않습니다. 2020년 2월 이후에 생성된 앱의 경우 REGION_ID.r이 App Engine URL에 포함됩니다. 이 날짜 이전에 만든 기존 앱의 경우 URL에서 리전 ID는 선택사항입니다.
Google Cloud Storage에 직접 업로드할 때는 잠시 후에 설명하겠지만 특정 URL에 HTTP POST를 수행합니다. 그러면 App Engine이 특정 업로드 서비스를 사용하여 해당 포스트를 처리해서 파일을 Google Cloud Storage에 씁니다. 파일 쓰기가 완료되면 App Engine은 업로드가 완료되었다고 앱에 알려줍니다. 앱은 완료 시에만 호출되므로 이 메소드를 사용하여 현재 최대 100테라바이트의 매우 큰 파일을 업로드할 수 있습니다.
App Engine 앱에서 Google Cloud Storage에 쓰는 방식은 인스턴스 시간과 비용이 발생하기 때문에 사용자가 Google Cloud storage에 직접 파일을 업로드하는 방법이 이보다 더 빠르고 비용 면에서 효과적입니다. 또한 파일 쓰기는 애플리케이션에 대한 요청 내에서 이루어지지 않습니다. 따라서 다른 경우라면 적용되었을 요청 제한 시간이 없어 대용량 파일도 업로드할 수 있습니다.
파일 업로드 구현
사용자 파일 업로드를 구현하려면 다음 안내를 따르세요.
CloudStorageTools 가져오기:
use google\appengine\api\cloud_storage\CloudStorageTools;
파일 업로드 후 createUploadUrl의 첫 번째 매개변수로 지정된 경로(위의 예시에서는 /upload_handler.php)에 POST가 수행됩니다. PHP 런타임은 올바른 $_FILES 수퍼 전역을 형성하고 tmp_filename은 Google Cloud Storage에 새로 업로드된 파일의 파일 이름을 가리킵니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eThe \u003ccode\u003eREGION_ID\u003c/code\u003e is a Google-assigned code based on the region selected during app creation, which is included in App Engine URLs for apps created after February 2020, and it does not directly correspond to a country or province.\u003c/p\u003e\n"],["\u003cp\u003eUploading files directly to Google Cloud Storage via HTTP POST is faster and more cost-effective than writing to it from the App Engine app because it avoids instance hour consumption and request timeouts, supporting files up to 100 Terabytes.\u003c/p\u003e\n"],["\u003cp\u003eTo implement user file uploads, you must import \u003ccode\u003eCloudStorageTools\u003c/code\u003e and use the \u003ccode\u003eCloudStorageTools::createUploadUrl()\u003c/code\u003e method to generate a unique upload URL that must be used within 10 minutes.\u003c/p\u003e\n"],["\u003cp\u003eUpon successful file upload, a POST request is sent to the specified handler, and the PHP runtime populates the \u003ccode\u003e$_FILES\u003c/code\u003e array, with \u003ccode\u003etmp_filename\u003c/code\u003e pointing to the uploaded file's location in Google Cloud Storage.\u003c/p\u003e\n"],["\u003cp\u003eFiles that are not moved using \u003ccode\u003emove_uploaded_file\u003c/code\u003e or \u003ccode\u003erename\u003c/code\u003e before the request finishes will be automatically removed from Google Cloud Storage.\u003c/p\u003e\n"]]],[],null,["# Allowing Users to Upload Files\n\n### Region ID\n\nThe \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e is an abbreviated code that Google assigns\nbased on the region you select when you create your app. The code does not\ncorrespond to a country or province, even though some region IDs may appear\nsimilar to commonly used country and province codes. For apps created after\nFebruary 2020, \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e`.r` is included in\nApp Engine URLs. For existing apps created before this date, the\nregion ID is optional in the URL.\n\nLearn more\n[about region IDs](/appengine/docs/legacy/standard/php/how-requests-are-routed#region-id). \nOK\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n| php-gen2\n|\n| /services/access). If you are updating to the App Engine PHP 7/8 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/php-differences) to learn about your migration options for legacy bundled services.\n\n\u003cbr /\u003e\n\nWhen you upload directly to Google Cloud Storage, you make an HTTP POST to a specific URL, which we'll\ndescribe in a moment. App Engine then uses a specific *upload service* to handle\nthe post and write the file to Google Cloud Storage. When the file write is complete, App Engine\nnotifies your app that the upload is complete. Because your app is invoked only\nupon completion, you can use this method to upload very large files, up to\nthe current maximum of 100 Terabytes.\n\nUser upload of files directly to Google Cloud Storage is faster and more cost-effective than\n[writing to Google Cloud Storage](/appengine/docs/legacy/standard/php/googlestorage#writing_files_from_your_app)\nfrom your App Engine app, because this consumes instance hours and incurs cost. Moreover, the file\nwrite does not occur within a request to the application. Therefore it is exempt\nfrom the [request timeout](/appengine/docs/legacy/standard/php/how-instances-are-managed#timeout)\nthat would otherwise apply and allows uploads of very large files.\n| **Note:** Starting from version 1.9.18, you can also upload files directly to your POST handler as long as the combined size is less than 32MB. See [this page](https://gae-php-tips.appspot.com/2015/03/09/direct-file-uploads-for-php-5-5/) for more details.\n\nImplementing file uploads\n-------------------------\n\nTo implement user file upload:\n\n1. Import `CloudStorageTools`:\n\n use google\\appengine\\api\\cloud_storage\\CloudStorageTools;\n\n2. Create the application specific upload URL, using the method\n [CloudStorageTools::createUploadUrl()](/appengine/docs/legacy/standard/php/refdocs/classes/google.appengine.api.cloud_storage.CloudStorageTools#method_createUploadUrl)\n in your `.php` file as follows:\n\n $options = ['gs_bucket_name' =\u003e $my_bucket];\n $upload_url = CloudStorageTools::createUploadUrl('/upload/handler', $options);\n\n See [`createUploadUrl` options](#createuploadurl_options) for details about\n available options. Note that `my_bucket` will be\n `YOUR_APP_ID`.\n \u003cvar translate=\"no\"\u003e\u003ca href=\"#appengine-urls\" style=\"border-bottom: 1px dotted #999\" class=\"devsite-dialog-button\" data-modal-dialog-id=\"regional_url\" track-type=\"progressiveHelp\" track-name=\"modalHelp\" track-metadata-goal=\"regionalURL\"\u003eREGION_ID\u003c/a\u003e\u003c/var\u003e`.r.appspot.com` if using the default bucket.\n3. Note that you must start uploading to this URL within 10 minutes of its\n creation. Also, you cannot change the URL in any way - it is signed and the\n signature is checked before your upload begins.\n\n4. Use this URL as the action for the form you use to accept uploads, for example:\n\n \u003cform action=\"{{ upload_url }}\" enctype=\"multipart/form-data\" method=\"post\"\u003e\n Files to upload: \u003cbr\u003e\n \u003cinput type=\"file\" name=\"uploaded_files\" size=\"40\"\u003e\n \u003cinput type=\"submit\" value=\"Send\"\u003e\n \u003c/form\u003e\n\nAfter the file(s) upload, a POST is made to the path specified as the first\nparameter to `createUploadUrl`; in the example above, this is\n`/upload_handler.php`. The PHP runtime forms the correct `$_FILES` super global,\nand `tmp_filename` refers to the filename of the newly uploaded file in Google Cloud Storage.\n\nFor example, suppose the content of upload_handler.php is the following: \n\n var_dump($_FILES);\n\nUploading a file called `hello.txt` might result in the following output: \n\n array(1) {\n ['uploaded_files']=\u003e\n array(5) {\n ['name']=\u003e string(14) 'hello.txt'\n ['type']=\u003e string(10) 'text/plain'\n ['tmp_name']=\u003e string(73) 'gs://my_bucket/L2FwcHMtdXBsb2FkL2Jsb2JzL2IxNUFBVGNJNXNTd0VqR0tFSUtDRGxadGc'\n ['error']=\u003e int(0)\n ['size']=\u003e int(1452)\n }\n }\n\nAfter the upload is complete, you can read the uploaded file using the\n`gs://` stream wrapper. You use `move_uploaded_file` like you normally would for\nany other uploaded file, for example: \n\n $file_name = $_FILES['uploaded_files']['name'];\n $temp_name = $_FILES['uploaded_files']['tmp_name'];\n move_uploaded_file($temp_name, \"gs://${my_bucket}/${file_name}.txt\");\n\n| **Note:** Any user uploaded files that are not moved using `move_uploaded_file` or `rename` before the request finishes will be automatically removed from Google Cloud Storage.\n\n`createUploadUrl` options\n-------------------------\n\nValid `createUploadUrl` options are shown in the following table:"]]