我正在尝试构建上传表单并收到通知(!)注意:未定义的索引:第 19 行 C:\wamp32\www\game\upload.php 中的 myfile 和我使用的代码是:
<?php
include("config.php");
session_start();
$_SESSION['uname']="123";
$uname = $_SESSION['uname'];
$upload = <<<EOT
Welcome, $uname<p>
Upload your image:
<form action='upload.php' method='POST' ectype='multipart/form-data'>
File:<input type='file' name='myfile'><input type='submit' name='submit' value='Upload!'>
</form>
EOT;
if (isset($_POST['submit']))
{
//get file attributes
$name = $_FILES['myfile']['name'];
$tmp_name = $_FILES['myfile']['tmp_name'];
if ($name)
{
//start upload process
$location = "upload/$name";
move_uploaded_file($tmp_name, $location);
$query = mysql_query("UPDATE users SET imagelocation='$location' WHERE uname='$uname'");
die("Your avatar has been uploaded! <a href='view.php'>Home</a>");
}
else
die("Please select a file!");
}
echo ($upload);
?>
我试过这样
$name = (isset($_FILES['myfile']['name'])); $tmp_name = (isset($_FILES['myfile']['tmp_name']));
在这种情况下,它不会显示通知,但它不会做任何工作。