我遇到文件上传,PHP和Parse的问题,虽然我还没有介绍Parse部分。我有一个带有input type = file元素的简单表单。
<input type="file" class="form-control" id="inputFirstName" name="inputFirstName" />
当我在回发到页面后尝试从$ _FILES数组中获取文件时,该数组为空。所有其他形式元素都很好。
我正在使用MAMP进行本地开发。我检查了php.ini文件,并打开了文件上传。我还应该检查或打开其他任何东西?我不知道我在哪里错了。完整表格。
<form class="form-horizontal" role="form" method="post" enctype="multipart/form">
<?php if($formPosted) : ?>
<div class="form-group">
<div class="col-md-10" id="formAlert<?php echo $type; ?> ">
<div class="alert alert-<?php echo $messageType ?>" role="alert">
<?php echo $message; ?>
</div>
</div>
</div>
<?php endif; ?>
<div class="form-group">
<label for="inputProfilePicture" class="col-md-3 control-label">Picture</label>
<div class="col-md-8">
<input type="file" class="form-control" id="inputProfilePicture" name="inputProfilePicture">
</div>
</div>
<div class="form-group">
<label for="inputFirstName" class="col-md-3 control-label">First Name *</label>
<div class="col-md-8">
<input type="hidden" id="inputType" name="inputType" value="<?php echo $type; ?>">
<input type="text" class="form-control" id="inputFirstName" name="inputFirstName" placeholder="First Name" required="required"/>
</div>
</div>
<div class="form-group">
<label for="inputLastName" class="col-md-3 control-label">Last Name *</label>
<div class="col-md-8">
<input type="text" class="form-control" id="inputLastName" name="inputLastName" placeholder="Last Name" required="required"/>
</div>
</div>
<div class="form-group">
<label for="inputEmail" class="col-md-3 control-label">Email *</label>
<div class="col-md-8">
<input type="email" class="form-control" id="inputEmail" name="inputEmail" placeholder="Email" required="required"/>
</div>
</div>
<div class="form-group">
<label for="inputPhone" class="col-md-3 control-label">Phone</label>
<div class="col-md-8">
<input type="tel" class="form-control" id="inputPhone" name="inputPhone" placeholder="XXX-XXX-XXXX" pattern='\d{3}[\-]\d{3}[\-]\d{4}'/>
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="col-md-3 control-label">Password *</label>
<div class="col-md-8">
<input type="password" class="form-control" id="inputPassword" name="inputPassword" placeholder="Password" required="required"/>
</div>
</div>
<div class="form-group">
<label for="inputUserType" class="col-md-3 control-label">User Type *</label>
<div class="col-md-8">
<select id="inputUserType" name="inputUserType" required="required">
<option disabled="disabled" selected="selected"></option>
<?php
$userTypeQuery = new ParseQuery("UserType");
$results = $userTypeQuery->find();
for($i = 0; $i < count($results); $i++) {
$role = $results[$i];
echo "<option value='" . $role->get("name") . "'>" . $role->get("name") . "</option>";
}
?>
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-3 col-md-8">
<!-- <button type="submit" class="btn btn-default"></button> -->
<input type="submit" class="btn btn-default" value="Create New <?php echo ucfirst($type); ?>"/>
</div>
</div>
</form>
PHP代码
var_dump($_FILES);
答案 0 :(得分:2)
在enctype="multipart/form-data"
标记中使用form
。