您好,我无法将文件上传到我的服务器,他们输入的数据库很好,路径正确,但由于某种原因文件不会进入。
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
foreach ($_FILES['ppt']['name'] AS $name) {
$i = 1;
$ppt = strtolower(str_replace(' ', '_', $name.$i));
$pathinfo = pathinfo($name, PATHINFO_EXTENSION);
$data = array(
'eid' => $_GET['id'],
'ppt_filename' => $name.$i,
'ppt_extension' => $pathinfo
);
$db::table('ppts')
->insert($data);
if ($_FILES['ppt']['tmp_name']) {
try {
move_uploaded_file($_FILES['ppt']['tmp_name'], DOCROOT . '/_data/ppt/' . $name . '.' . $pathinfo);
} catch (Exception $e) {
echo 'broken';
exit;
}
$i++;
}
}
}
这是用于处理帖子的PHP。
<div class="card bg-grey">
<h4 class="card-header bg-blue text-white text-bold">Uploads</h4>
<div class="card-block">
<div id="<?php echo $field_name; ?>" class="form-group <?php echo $_ERROR[$field_name] ? ' has-danger' : ''; ?>">
<input <?php echo ($_SESSION['level'] == 1 || $event->created_by == $_SESSION['id'] ? '' : 'readonly="readonly"'); ?> type="file" name="ppt[]" class="form-control" placeholder=""/>
<label>Powerpoint</label>
</div>
</div>
</div>
这是我提交文件的HTML