【问题标题】:Google App Engine empty form upload field submission issueGoogle App Engine 空表单上传字段提交问题
【发布时间】:2014-03-01 12:57:20
【问题描述】:

我正在使用 Google Cloud Storage 制作我的第一个 PHP Google App Engine 应用程序。

我有一个表单,其中包含几个上传字段。一旦我使用一个字段上传图像并将其余部分保留为空,就会在我的云存储桶中为那些我没有上传任何图像的字段创建一个垃圾文件。这就是我的表单的样子

<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>

我使用CloudStorageTools::createUploadUrl 方法得到$postUrl。哪个工作正常,一旦提交表单,var_dump($_FILES) 会在我上传的字段中显示值,而带有空值的空值显示错误代码为 4,这意味着未使用该字段上传文件。如何在我的 Cloud Storage 存储桶中制作带有未知图像的垃圾文件。

如何阻止这种情况发生? 如果无法停止,如何将其从存储桶中删除? ($_FILES['image2']['tmp_name'] 和 $_FILES['image2']['name'] 是空的,所以我不知道如何在不知道图像名称的情况下获取 publiUrl)。

谢谢!

【问题讨论】:

  • 这绝对是个问题,我重现了这个问题。我已经在内部提交了错误报告并将跟进。

标签: php google-app-engine file-upload google-cloud-storage


【解决方案1】:

看起来像两个合法的错误:1)如果不移动,所有临时上传的文件都应该取消链接(删除)(默认机制不起作用,因为它使用不处​​理 gs:// 的系统取消链接,因为在用户空间中定义) , 2) PHP 中的空文件不会写入临时目录,但云存储代理默认创建它们,因此应更新 App Engine PHP 运行时以删除它们。

根据文档,http://www.php.net/manual/en/features.file-upload.post-method.php

The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed.

正在修复并希望在下一个版本中包含它。

【讨论】:

  • 非常感谢boombatower。
猜你喜欢
  • 1970-01-01
  • 2011-09-11
  • 1970-01-01
  • 1970-01-01
  • 2015-05-31
  • 2011-09-06
  • 1970-01-01
  • 1970-01-01
  • 2010-10-03
相关资源
最近更新 更多