提问人:Alexandre KUO 提问时间:6/8/2017 最后编辑:RiggsFollyAlexandre KUO 更新时间:6/8/2017 访问量:45
未定义的索引文件(从这个论坛尝试了很多解决方案,但不起作用......
undefined index file (Tried a lot of solutions from this forum but not working ...)
问:
很抱歉问已经看过很多次的问题,但它似乎对我不起作用,所以我不得不问你们...... 提前致谢 !
这是我的HTML表单:
<form action="action/actionindex.php" method="post">
<label style="text-align:center;"><b>Changer d'image</b></label>
<input type="file" name="file" id="indeximage" style="margin-left:500px;"/>
<div class="bg" style="background-image:url('../image/papierpeint.jpg');width:95%;margin:0 auto;height:auto;">
<div class="welcometxt">
<ul>
<label><b>Titre de l'article (Saut de ligne : <img src="../image/sautligne.png"/>| Gras : <img src="../image/gras.png"/>| Italique : <img src="../image/italique.png"/>| Souligné : <img src="../image/souligne.png"/>)</b></label>
<textarea name="indexh2" rows="1" cols="80">
<?php getDesc(1) ?>
</textarea></br>
<label><b>Contenu l'article (Saut de ligne : <img src="../image/sautligne.png"/>| Gras : <img src="../image/gras.png"/>| Italique : <img src="../image/italique.png"/>| Souligné : <img src="../image/souligne.png"/>)</b></label>
<textarea name="indexp" rows="15" cols="110">
<?php getDesc(2)?>
</textarea>
<input type="submit" name="submit" value="Modifier"></br>
这是 actionindex.php :
if(isset($_POST['submit'])){
$name = $_FILES['file']['name'];
echo 'nom : '.$name;
$temp_name = $_FILES['file']['tmp_name'];
echo 'dossier temp : '.$temp_name;
if(isset($name)){
if(!empty($name)){
$location = '../../image/';
if(move_uploaded_file($temp_name, $location)){
echo 'File uploaded successfully';
}
}
} else {
echo 'You should select a file to upload !!';
}
}
希望你们能帮帮我,谢谢!!
答:
-3赞
vural
6/8/2017
#1
尝试更改表单代码,如下所示:
<form action="action/actionindex.php" method="post" enctype="multipart/form-data">
我希望,它会有所帮助。
3赞
Halcyon
6/8/2017
#2
如果提供,则没有上传的文件。$_FILES["file"]
undefined index file
表单中缺少您。enctype="multipart/form-data"
0赞
Ahmed Ginani
6/8/2017
#3
当您的表单包含任何元素时,请使用 multipart/form-data:<input type="file">
<form action="action/actionindex.php" method="post" enctype="multipart/form-data">
阅读更多关于 multipart/form-data 的信息 enctype='multipart/form-data' 是什么意思?
评论
$_FILES["file"]
undefined index file
enctype="multipart/form-data"