PHP 5 telah mencapai akhir dukungan dan akan
dihentikan penggunaannya
pada 31 Januari 2026. Setelah penghentian penggunaan, Anda tidak akan dapat men-deploy aplikasi PHP 5, meskipun organisasi Anda sebelumnya menggunakan kebijakan organisasi untuk mengaktifkan kembali deployment runtime lama. Aplikasi PHP 5 yang sudah ada akan terus berjalan dan menerima traffic setelah
tanggal penghentiannya. Sebaiknya Anda bermigrasi ke versi PHP terbaru yang didukung.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
ID region
REGION_ID adalah kode singkat yang ditetapkan Google berdasarkan region yang Anda pilih saat membuat aplikasi. Kode ini tidak sesuai dengan negara atau provinsi, meskipun beberapa ID region mungkin tampak mirip dengan kode negara dan provinsi yang umum digunakan. Untuk aplikasi yang dibuat setelah Februari 2020, REGION_ID.r disertakan dalam URL App Engine. Untuk aplikasi lama yang dibuat sebelum tanggal tersebut, ID region bersifat opsional dalam URL.
Saat mengupload langsung ke Google Cloud Storage, Anda membuat HTTP POST ke URL tertentu, yang akan
kami jelaskan sebentar lagi. App Engine kemudian menggunakan layanan upload tertentu untuk menangani postingan dan menulis file ke Google Cloud Storage. Ketika penulisan file selesai, App Engine
akan memberi tahu aplikasi Anda bahwa upload telah selesai. Karena aplikasi hanya dipanggil setelah selesai, Anda dapat menggunakan metode ini untuk mengupload file yang berukuran sangat besar, hingga batas maksimum 100 Terabyte saat ini.
Mengupload file secara langsung oleh pengguna ke Google Cloud Storage lebih cepat dan lebih hemat biaya daripada menulis ke Google Cloud Storage dari aplikasi App Engine Anda, karena hal ini menghabiskan jam kerja instance dan menimbulkan biaya. Selain itu, penulisan
file tidak terjadi dalam permintaan ke aplikasi. Oleh karena itu, metode ini dikecualikan dari waktu tunggu permintaan yang akan berlaku dan mengizinkan upload file yang sangat besar.
Menerapkan upload file
Untuk menerapkan upload file pengguna:
Impor CloudStorageTools:
use google\appengine\api\cloud_storage\CloudStorageTools;
Lihat opsi createUploadUrl untuk mengetahui detail tentang
opsi yang tersedia. Perhatikan bahwa my_bucket akan menjadi
YOUR_APP_ID.
REGION_ID.r.appspot.com jika menggunakan bucket default.
Perhatikan bahwa Anda harus mulai mengupload ke URL ini dalam waktu 10 menit setelah
dibuat. Selain itu, Anda tidak dapat mengubah URL dengan cara apa pun - URL telah ditandatangani dan tanda tangan tersebut diperiksa sebelum upload Anda dimulai.
Gunakan URL ini sebagai tindakan untuk formulir yang Anda gunakan untuk menerima upload, misalnya:
Setelah file diupload, POST dibuat ke jalur yang ditentukan sebagai parameter
pertama ke createUploadUrl; dalam contoh di atas, ini adalah
/upload_handler.php. Runtime PHP membentuk $_FILES super global yang benar, dan tmp_filename merujuk pada nama file dari file yang baru diupload di Google Cloud Storage.
Misalnya, konten upload_handler.php adalah sebagai berikut:
var_dump($_FILES);
Mengupload file bernama hello.txt dapat menghasilkan output berikut:
Setelah upload selesai, Anda dapat membaca file yang diupload menggunakan wrapper streaming gs://. Gunakan move_uploaded_file seperti biasa untuk
file lainnya yang diupload, misalnya:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-19 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:"]]