I'm making my first PHP Google App Engine application using Google Cloud Storage.
I have a form with few upload fields in it. Once I upload an image using one field and keep the rest empty, a junk file is made inside my cloud storage bucket for those field which I did not upload any image. This is how my form look like
<form method="post" class="admin" action="<?PHP echo $postUrl; ?>" enctype="multipart/form-data">
<input type='file' name='image1'>
<input type='file' name='image2'>
<input type='submit' name='submitBttn' value='submit'>
</form>
I get $postUrl
using CloudStorageTools::createUploadUrl
method. Which works fine and once the form is submitted a var_dump($_FILES)
displays values in the field which I uploaded and the empty one with empty values which has a error code of 4 which means a file is not uploaded using that field. How ever a junk file is made in my Cloud Storage bucket with a unknown image.
How do I stop this happening? If it cannot be stopped, how do I delete it from the bucket? ($_FILES['image2']['tmp_name'] and $_FILES['image2']['name'] are empty, so I don't know how to get the publiUrl without knowing the image name).
Thanks!