我有这个 HTML 代码用于将文件发布到我的上传脚本:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CONTISEC PORTAL - NEW USER</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="buttcss/gstyle_buttons.css" type="text/css" media="screen">
<link rel="stylesheet" type="text/css" href="usercon.css" />
</head>
<body>
<div id="page-wrap">
<p>CREATE NEW CLIENT USER ACCOUNT BY ENTERTING CLIENT REFERENCE NUMBER (supplied by Pershing) AND DESIRED USERNAME.</p>
<div id="contact-area">
<form method="post" action="fileproc.php">
<enctype="multipart/form-data">
<label for="client_ref">BROWSE:</label>
<input type="file" name="file" id="file" />
<label for="client_ref">SELECT FILE:</label>
<select name="file">
<option value="assets" >ASSETS (DAILY)</option>
<option value="stock_names" >STOCK_NAMES (DAILY)</option>
<option value="client_names" >CLIENT_NAMES</option>
</select>
<div class="buttons">
<button class="action redbtn" type="submit"><span class="label">SUBMIT</span></button>
</form>
<div style="clear: both;"></div>
</div>
</div>
</body>
</html>
这是我的上传脚本(来自 w3 学校):
<?php
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br>";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
}
?>
但是,当页面加载时,它会显示“未定义索引”错误。有谁知道为什么会这样?