Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有图片上传的PHP表单_Php_Email_Forms_Image_Upload - Fatal编程技术网

带有图片上传的PHP表单

带有图片上传的PHP表单,php,email,forms,image,upload,Php,Email,Forms,Image,Upload,我如何做一个php和xhtml表单,允许用户上传图像,并在提交所有数据后发送到我的电子邮件 在谷歌上搜索教程并自己学习。这个问题太广泛了,不能在这个网站上发布。你自己试试看,如果你能想出一个你没有答案的具体问题,就在这里问。以下是一些让您开始学习的内容: 在谷歌上搜索教程并自己学习。这个问题太广泛了,不能在这个网站上发布。你自己试试看,如果你能想出一个你没有答案的具体问题,就在这里问。以下是一些让您开始学习的内容: PHP主站点本身还包括一些关于推荐做法和陷阱的好信息,以及一些示

我如何做一个php和xhtml表单,允许用户上传图像,并在提交所有数据后发送到我的电子邮件

在谷歌上搜索教程并自己学习。这个问题太广泛了,不能在这个网站上发布。你自己试试看,如果你能想出一个你没有答案的具体问题,就在这里问。以下是一些让您开始学习的内容:


在谷歌上搜索教程并自己学习。这个问题太广泛了,不能在这个网站上发布。你自己试试看,如果你能想出一个你没有答案的具体问题,就在这里问。以下是一些让您开始学习的内容:


PHP主站点本身还包括一些关于推荐做法和陷阱的好信息,以及一些示例代码-请参见“”部分。

PHP主站点本身还包括一些关于推荐做法和陷阱的好信息,以及一些示例代码-请参见“”部分。

试试这个

<?
//print_r($_POST);

if($_POST["action"] == "Upload Image")
{
unset($imagename);

if(!isset($_FILES) && isset($HTTP_POST_FILES))
$_FILES = $HTTP_POST_FILES;

if(!isset($_FILES['image_file']))
$error["image_file"] = "An image was not found.";


$imagename = basename($_FILES['image_file']['name']);
//echo $imagename;

if(empty($imagename))
$error["imagename"] = "The name of the image was not found.";

if(empty($error))
{
$newimage = "images/" . $imagename;
//echo $newimage;
$result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage);
if(empty($result))
$error["result"] = "There was an error moving the uploaded file.";
}

}

?>


<form method="POST" enctype="multipart/form-data" name="image_upload_form" action="<?$_SERVER["PHP_SELF"];?>">
<p><input type="file" name="image_file" size="20"></p>
<p><input type="submit" value="Upload Image" name="action"></p>
</form>

<?
if(is_array($error))
{
while(list($key, $val) = each($error))
{
echo $val;
echo "<br>\n";
}
}
?>

试试这个

<?
//print_r($_POST);

if($_POST["action"] == "Upload Image")
{
unset($imagename);

if(!isset($_FILES) && isset($HTTP_POST_FILES))
$_FILES = $HTTP_POST_FILES;

if(!isset($_FILES['image_file']))
$error["image_file"] = "An image was not found.";


$imagename = basename($_FILES['image_file']['name']);
//echo $imagename;

if(empty($imagename))
$error["imagename"] = "The name of the image was not found.";

if(empty($error))
{
$newimage = "images/" . $imagename;
//echo $newimage;
$result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage);
if(empty($result))
$error["result"] = "There was an error moving the uploaded file.";
}

}

?>


<form method="POST" enctype="multipart/form-data" name="image_upload_form" action="<?$_SERVER["PHP_SELF"];?>">
<p><input type="file" name="image_file" size="20"></p>
<p><input type="submit" value="Upload Image" name="action"></p>
</form>

<?
if(is_array($error))
{
while(list($key, $val) = each($error))
{
echo $val;
echo "<br>\n";
}
}
?>


给我一个codez?请更具体地说明您在处理文件上传时遇到的问题。给我一个codez?请更具体地说明您在处理文件上载时遇到的问题。