我正在尝试将文件上传到文件夹,这是我的错误和代码。
[01-Feb-2018 22:07:26 America/New_York] PHP Notice: Undefined index: myimage in /home/grampmkn/public_html/admin/addpost.php on line 27
[01-Feb-2018 22:07:26 America / New_York] PHP注意:第28行/home/grampmkn/public_html/admin/addpost.php中的未定义索引:myimage
<?php
if($_SERVER["REQUEST_METHOD"] == "POST"){
echo "test6";
if(isset($_POST['itemname']) and isset($_POST['price']) and isset($_POST['myimage'])){
echo "test5";
if(isset($_POST["submit"])) {
$itemname = $_POST['itemname'];
$price = $_POST['price'];
$location="tracylynn/";
$name=$_FILES['myimage']['name'];
$temp_name=$_FILES['myimage']['tmp_name'];
echo "test3";
if(isset($name)){
echo "test";
move_uploaded_file($temp_name, $location.$name);
}
}
}
}
?>
<form class="form-horizontal"
style="padding-right: 50px; padding-left: 50px; padding-top: 20px;"
action="" method="post">
<div class="form-group">
<label class="control-label col-sm-2">Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="itemname" id="itemname"
placeholder="Item name..">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Price:</label>
<div class="col-sm-10">
<input type="number" class="form-control" name="price" id="price"
placeholder="Price..">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Image:</label>
<div class="col-sm-10">
<input type="file" name="myimage" id="myimage">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" name="submit" id="submit" class="btn btn-default">Submit</button>
</div>
</div>
</form>
我已经尝试到处搜索解决方案,我尝试的所有内容都无法正常工作。