Php uploads files to the specified folder

if you want to upload a local file to another local folder, use < form action= "doAction.php" method= "post" enctype= "multipart/form-data" > to upload

try the code on the Internet, but you can"t get out, and you won"t report an error

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
</head>
<body>
<form action="doAction.php" method="post" enctype="multipart/form-data">
<!-- <input type="hidden" name="MAX_FILE_SIZE" value="176942" /> -->
:<input type="file" name="myFile" />
<!-- <input type="file" name="myFile"  accept="image/jpeg,image/gif,image/png"/><br /> -->
<input type="submit" value="" />
</form>
</body>
</html>

doAction.php

<?php 

//$_FILES:
print_r($_FILES);
$filename=$_FILES["myFile"]["name"];
$type=$_FILES["myFile"]["type"];
$tmp_name=$_FILES["myFile"]["tmp_name"];
$size=$_FILES["myFile"]["size"];
$error=$_FILES["myFile"]["error"];


if (move_uploaded_file($tmp_name, "uploads/".$filename)) {
    $mes="";
} else {
    $mes="";
}
 echo $mes;
?>

ask God to point out my problem!

Mar.07,2021

breakpoint debugging, first determine whether the request is in the doAction: echo some strings in doAction


the first step is to determine whether the php file can receive the value from the html. If so, see whether the next value meets the requirements and whether the path name to be uploaded is correct.

Menu