forked from JessePresnell/dynamite-images
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload.php
More file actions
20 lines (17 loc) · 900 Bytes
/
Copy pathupload.php
File metadata and controls
20 lines (17 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageTools;
$app_host = array_pop(@explode("~", $_SERVER["APPLICATION_ID"])) . ".appspot.com";
$options = [ 'gs_bucket_name' => $app_host ];
$upload_url = CloudStorageTools::createUploadUrl('/upload.php', $options);
if(count($_FILES)) {
$gs_name = $_FILES['uploaded_files']['tmp_name'];
move_uploaded_file($gs_name, 'gs://' . $app_host .'/' . $_FILES['uploaded_files']['name']);
header("Location: /edit.html?img=" . $_FILES['uploaded_files']['name']);
}
?>
<form action="<?php echo $upload_url?>" enctype="multipart/form-data" method="post" style="padding:1em;">
Images to upload: <br>
<input type="file" name="uploaded_files" size="40" accept="image/*">
<input type="submit" value="Upload" class="btn btn-primary">
</form>