<form action='' method='post'>
<input type="file" class="form-control" name="kk">
<input type="submit" class="form-control" name="submit">
</form>
<?php
if(isset($_POST['submit'])){
echo $_FILES["kk"]["name"];
}
?>
嗨,我是php的新手,在这段代码中未定义索引kk即将上传文件,我只想要文件名...请帮帮我
答案 0 :(得分:3)
添加enctype =&#34; multipart / form-data&#34;形成标签
答案 1 :(得分:2)
当您需要上传文件
时,您需要传递enctype="multipart/form-data"
<form action='' method='post' enctype="multipart/form-data">
<input type="file" class="form-control" name="kk">
<input type="submit" class="form-control" name="submit">
</form>
<?php
if(isset($_POST['submit'])){
echo $_FILES["kk"]["name"];
}
?>