当我尝试上传文本文件时得到“未定义指数:UsernamesInput在”未定义指数:UsernamesInput在
我想看着,我发现一些例子中的问题,但我,他们没有任何意义我具体代码
这是我的HTML代码:
<div class="container forms">
<form action="verify.php" method="POST">
<div class="col-sm-4">
<fieldset class="form-group">
<label for="exampleTextarea">Emails</label>
<textarea class="form-control" id="exampleTextarea" rows="5" placeholder="Emails here..."></textarea>
</fieldset>
<fieldset class="form-group middle">
<label for="exampleInputFile">Email input</label>
<input type="file" class="form-control-file" id="exampleInputFile">
<small class="text-muted">Upload the E-mail adresses for registering</small>
</fieldset>
</div>
<div class="col-sm-4">
<fieldset class="form-group">
<label for="exampleTextarea">Passwords</label>
<textarea class="form-control" id="exampleTextarea" rows="5" placeholder="Passwords here..."></textarea>
</fieldset>
<fieldset class="form-group middle">
<label for="exampleInputFile">Password input</label>
<input type="file" class="form-control-file" id="exampleInputFile">
<small class="text-muted">Upload the Passwords for registering</small>
</fieldset>
</div>
<div class="col-sm-4">
<fieldset class="form-group">
<label for="exampleTextarea">Usernames</label>
<textarea class="form-control" id="exampleTextarea" rows="5" placeholder="Usernames here..."></textarea>
</fieldset>
<fieldset class="form-group middle">
<label for="exampleInputFile">Username input</label>
<input type="file" name="UsernamesInput" class="form-control-file" id="exampleInputFile">
<small class="text-muted">Upload the Usernames for registering</small>
</fieldset>
</div>
<input type="submit" name="submit" value="Create Accounts!" class="btn btn-info btn-block">
</form>
</div>
和我的PHP代码:
<?php
$_SERVER['REQUEST_METHOD'];
$name = $_FILES['UsernamesInput']['name'];
$extention = strtolower(substr($name, strpos($name, '.') + 1));
$type = $_FILES['UsernamesInput']['type'];
//$size = $_FILES['UsernamesInput']['size'];
$tmp_name = $_FILES['UsernamesInput']['tmp_name'];
if (isset($name)) {
if (!empty($name)) {
if (($extention == 'txt') and ($type == 'text/plain')) {
$location = 'uploads/';
if (move_uploaded_file($tmp_name, $location . $name)) {
echo 'Uploaded!';
} else {
echo 'There was an error';
}
} else {
echo 'Error, file must be in text format.';
}
}
}
?>
由于提前,
我觉得输入类型=“文件”还需要一个名称的属性,它是什么你在这里失踪。 – Maximus2012
你真的上传了与该字段对应的文件吗? – Maximus2012
@ Maximus2012是无所谓我上传或保留空它不断返回相同的错误 – Naomi