这是我的错误:
Notice: Undefined index: file in
C:\xampp\htdocs\Project\Template1\users\index.PHP on line 21 Notice:
Undefined index: file in
C:\xampp\htdocs\Project\Template1\users\index.PHP on line 23 please
uploaded
如何摆脱它?
<form action="index.PHP" method="post" enctype="multipart/form-data"> <input type="file" name="file" id="file"><br><br> <input type="submit" value="submit" name="submit"> </form>
<?PHP $name = $_FILES['file']['name']; $temp_name = $_FILES['file']['temp_name']; if (isset($name)) { if (!empty($name)) { $location = '../uploads/'; } if (move_uploaded_file($temp_name,$location.$name)) { echo 'uploaded'; } } else { echo 'please uploaded'; } ?>
试试这个
原文链接:https://www.f2er.com/php/138569.html<?PHP if(isset($_POST['submit'])){ $name = $_FILES['file']['name']; $temp_name = $_FILES['file']['tmp_name']; if(isset($name)){ if(!empty($name)){ $location = '../uploads/'; if(move_uploaded_file($temp_name,$location.$name)){ echo 'File uploaded successfully'; } } } else { echo 'You should select a file to upload !!'; } } ?>