Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.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_File Upload_Undefined Index - Fatal编程技术网

Php 未定义索引:图像

Php 未定义索引:图像,php,file-upload,undefined-index,Php,File Upload,Undefined Index,为什么这不起作用?正在尝试使用PHP上载文件。问题中的文件是只需要存储文件路径的图像。正在尝试此代码,但不起作用。有什么帮助吗 <html> <body> <form action="book_create.php" method="POST"> title: <input type="text" name="title"/><br> authors: <input type="text" name="authors"/>&

为什么这不起作用?正在尝试使用PHP上载文件。问题中的文件是只需要存储文件路径的图像。正在尝试此代码,但不起作用。有什么帮助吗

<html>
<body>
<form action="book_create.php" method="POST">
title: <input type="text" name="title"/><br>
authors: <input type="text" name="authors"/><br>
description: <textarea type="text" name="description"></textarea><br>
price: <input type="text" name="price"/><br>
image: <input type="file" name="image"/><br>
content: <input type="file" name="content"/><br>
<input type="submit" value="book_create"/>
</form>
</body>
</html>

标题:
作者:
说明:
价格:
图像:
内容:
PHP:

if ($_FILES["image"]["error"] > 0)
{
echo "Error: " . $_FILES["image"]["error"] . "<br>";
}
else
{
echo "Upload: " . $_FILES["image"]["name"] . "<br>";
echo "Type: " . $_FILES["image"]["type"] . "<br>";
echo "Size: " . ($_FILES["image"]["size"] / 1024) . " kB<br>";
echo "Stored in: " . $_FILES["image"]["tmp_name"];
 }
if($\u文件[“图像”][“错误”]>0)
{
echo“Error:”.$\u文件[“image”][“Error”]。“
”; } 其他的 { echo“上传:.”文件[“图像”][“名称”]。“
”; echo“Type:”.$\u文件[“image”][“Type”]。“
”; 回显“大小:”($_文件[“图像”][“大小”]/1024)。“kB
”; echo“存储在:“.$”文件[“图像”][“tmp_名称”]; }
继续获取未定义的索引错误是否已使用“图像”


谢谢

您的表单缺少
enctype
属性:

<form action="book_create.php" method="POST" enctype="multipart/form-data">

您的表单缺少
enctype
属性:

<form action="book_create.php" method="POST" enctype="multipart/form-data">

您需要在表单标签中包含
enctype=“multipart/form data”
您需要在表单标签中包含
enctype=“multipart/form data”