我有一个表单,我必须按类别上传图像并将选定的类别图像移动到特定文件夹但是当我提交表单时发生以下错误 (!)注意:未定义索引:图片C:\ wamp \ www \ movies海报admin \ insertform.php第26行 pic是文件的名称,但不知道为什么它没有获得该值 我知道这是一个非常基本的问题,但我不知道为什么会出现这个错误
$imageprice=$_POST['imageprice'];
$imagedescription=$_POST['imagedescription'];
$type=$_POST['category'];
if ($type="celeb") {
$uploadDir = 'C:/wamp/www/Movies Poster Site/celeb/'; //Image Upload Folder
$fileName = $_FILES['pic']['name'];
$tmpName = $_FILES['pic']['tmp_name'];
$fileSize = $_FILES['pic']['size'];
$fileType = $_FILES['pic']['type'];
$filePath = $uploadDir . $fileName;
$filename = $fileName;
$ext = pathinfo($filename, PATHINFO_EXTENSION);
//$date = date_create();
//$fileName= date_timestamp_get($date).".".$ext;
$filePath = $uploadDir . $fileName;
if (isset($fileName)) {
# code...
$result = move_uploaded_file($tmpName, $filePath);
}
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
`
`$sql="INSERT INTO celeb ".
"(image_name,price,description,Type) ".
"VALUES ".
"('$filePath','$imageprice','$imagedescription','$type') ";
mysql_select_db('poster');
$retval = mysql_query( $sql, $connection );
if(! $retval )
{
die('Could not enter data: ' . mysql_error());
}
else
{
echo" <div class='end'>";
echo "Data Entered";
echo"</div>";
mysql_close($connection);
}
这是表格
<form method="post">
<div class="insertform">
<!-- <input type="text" placeholder="image.jpg" name="imagename" id="imagename"><br>
-->
Select Image Category:<br>
<input type="radio" name="category" value="comic">Comic Posters<br>
<input type="radio" name="category" value="celeb">Celeb Posters<br>
<input type="radio" name="category" value="islamic">Islamic Posters<br>
<input type="radio" name="category" value="tv">TV Posters<br>
<input type="radio" name="category" value="motor">Motor Posters<br />
<input type="radio" name="category" value="sports">Sports Posters<br><br />
Image Name :<br>
<input style="margin-left:10px;" id="uploadImage" required="required" name="pic" type="file" size="4
000000" accept="image/gif, image/jpeg, image/x-ms-bmp, image/x-png" > <br>
Image Price :<br>
<input type="text" placeholder="Rs xxx" name="imageprice" id="price"><br>
Image Description :<br>
<input type="text" name="imagedescription" id="description" height="300px"><br /><br>
<input type="submit" name="submit" value="Submit">
</div>
答案 0 :(得分:-1)
尝试这样,
$fileName = $_FILES['pic']['name'][0];