PHP接收文件的代码。
<?php
if (isset($_FILES["file"]["name"])) {
echo "success\n";
$name = $_FILES["file"]["name"];
$tmp_name = $_FILES['file']['tmp_name'];
$error = $_FILES['file']['error'];
echo "name is \n";
echo $name;
echo "\necho done";
echo "\nname is \n";
echo $tmp_name;
echo "\necho done";
if (!empty($name)) {
$location = './upload/';
if (move_uploaded_file($tmp_name, $location.$name)){
echo 'Uploaded\n';
}
} else {
echo 'please choose a file\n';
}
}else{
echo "error\n";
}
?>