<form method="post" action="" enctype="multypart/form-data">
<div class="row" style="margin-left:70px">
<p>Carousel Number</p>
<select name="carousel_num">
<option value="1">1</option>
<option value="2">2</option>
<option value="2">3</option>
</select>
</div>
<input type="file" name="pic">
<input type="submit" name="submit" class="btn btn-primary" value="Upload">
</form>
<?php
if(isset($_POST['submit'])){
$carousel_num = $_POST["carousel_num"];
$tmpname = $_FILES["pic"]['tmp_name'];
$filename = $_FILES["pic"]['name'];
$file_ext_arr = explode(".",$filename);
$file_name = $file_ext_arr[0];
$ext = end($file_ext_arr);
if($ext == "jpg" || $ext == "png" || $ext == "jpeg" || $ext == "gif"){
move_uploaded_file("Carousel_$carousel_num","./upload/".$ext);
echo "<script>history.go(-1);</script>";
}else{
echo "<script>alert(\"only 'jpg, png, jpeg, gif' file is permitted.\");history.back(-1);</script>";
}
}
?>
大家好,这段代码出错了
Notice: Undefined index: pic in /Applications/MAMP/htdocs/astral/special.php on line 49
请帮助我!!
答案 0 :(得分:2)
应为enctype="multipart/form-data"
<form method="post" action="" enctype="multipart/form-data">
答案 1 :(得分:1)
不是enctype='multypart/form-data'
。正确的是enctype='multipart/form-data'
。
<form method="post" action="" enctype="multipart/form-data">