當我嘗試上傳文本文件時得到「未定義指數: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