I have a php script read_write.php that it is used to upload files to google cloud storage. The script works fine and uploads successfully my files, to my bubket at google cloud storage. The only problem is that after files uploaded, by pressing upload, the page is redirected to a link used by google (see at my form bellow),
action="<?php echo $upload_url?>"
I dont want to be redirected to this link. I want after the file to be redirected back to my php page which is read_write.php Any idea how to fix this? This is my code:
<?php
require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageTools;
$options = [ 'gs_bucket_name' => 'carb' ];
$upload_url = CloudStorageTools::createUploadUrl('/read_write', $options);
if(isset($_POST['do-upload']) AND $_POST['do-upload'] === "yes"){
$yesupload = $_POST['do-upload'];
preg_match("/yes/", "".$yesupload."");
$filename = $_FILES['testupload']['name'];
$gs_name = $_FILES['testupload']['tmp_name'];
$temp = explode(".",$_FILES["testupload"]["name"]);
$newfilename = substr(md5(time()), 0, 100) . '.' .end($temp);
move_uploaded_file($gs_name, 'gs://carb/'.$newfilename.'');
$object_image_file = 'gs://carb/'.$newfilename.'';
$object_image_url = CloudStorageTools::getImageServingUrl($object_image_file, ['size' => 400, 'crop' => true]);
mysql_query("UPDATE `myusers` SET `profile`= '" . mysql_real_escape_string($object_image_url) . "' WHERE `user_id`= " . (int)$session_user_id);
//---I use this header here, but there is no redirecton to this, after pressing upload button
header('Location: read_write.php');
exit();
}
//---displays the image i have upload
if(empty($user_data['profile'])=== false ){
echo ' <img src="', $user_data['profile'], '" alt="', 'Image 400k max">';
}else
echo'<img src="img/photo.jpg"/>';
<form class="SomeSpaceDude" action="<?php echo $upload_url?>" enctype="multipart/form-data" method="post">
<p>Files to upload: </p> <br>
<input type="hidden" name="do-upload" value="yes">
<input class="SomeSpaceDude topcoat-button" type="file" name="testupload" >
<input class="SomeSpaceDude topcoat-button" type="submit" value="Upload">
</form>