首页 > 解决方案 > 错误 缺少文件部分 PHP Google 云平台 POST

问题描述

我只是试图将订阅表单中的文本“发布”到一个简单的电子邮件 php 文件,但谷歌云给出了这个错误:

<Error>
<Code>InvalidArgument</Code>
<Message>Invalid argument.</Message>
<Details>Missing file part</Details>
</Error>

我尝试了一些方法,包括直接写入 Google Cloud 中的存储桶,但我宁愿将文本通过电子邮件发送到某个地址。为什么缺少文件部分?

这是我的表单代码:

<form action="email.php" method="post" enctype="multipart/form-data">
<input type="text" name="email" size="15" style="font-size:29px;" id="email" required placeholder="Email">
<input value="RSVP" class="button" name="button" style="font-size:29px;" type="submit">
</form>

这是我的 php 文件:

<?php

$to = "email@gmail.com"; // 
$from = "no-reply@website.com"; // 

$headers = "From: " . $from . "rn";

$subject = "New subscription";
$body = "New user subscription: " . $_POST['email'];
if( filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) )
{
if (mail($to, $subject, $body, $headers, "-f " . $from))
{
echo 'Your e-mail (' . $_POST['echo $this->mail'] . ') has been added to our mailing list!';
}
else
{
echo 'There was a problem with your e-mail (' . $_POST['email'] . ')';
}
}
?>

标签: phphtml

解决方案


推荐阅读