Php文件上载返回false

Php文件上载返回false,php,image,file,Php,Image,File,我正试图上传一张图片。关于上传图片的代码部分取自w3school。但是当代码涉及if时,它返回false,并且不会给出错误。代码是: set_time_limit(0); ini_set('upload_max_filesize', '500M'); ini_set('post_max_size', '500M'); ini_set('max_input_time', 4000); // Play with the values ini_set('max_execution_time', 400

我正试图上传一张图片。关于上传图片的代码部分取自w3school。但是当代码涉及if时,它返回false,并且不会给出错误。代码是:

set_time_limit(0);
ini_set('upload_max_filesize', '500M');
ini_set('post_max_size', '500M');
ini_set('max_input_time', 4000); // Play with the values
ini_set('max_execution_time', 4000); // Play with the values
print_r($_FILES);
$target_dir = "uploads/";
@$topic = htmlspecialchars($_POST["topic"]);
@$textarea = htmlspecialchars($_POST["textarea"]);
try {
   if(move_uploaded_file($_FILES["file_input"]["tmp_name"], $target_dir.$_FILES["file_input"]["name"])){
       echo "upload succesfull";
   }else{
       echo"upload failed";
   }
}catch (Exception $e){
    echo $e->getMessage();
}
这是一个名为file_operations.php的文件。有一个文件名为file_form.php。php文件有一个表单,表单中有一个类型为file的输入html标记。表单的操作是file_operations.php。“如果(移动上传的文件($\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\。我的表格是:

<form action="save_operations.php" method="post" enctype="multipart/form-data">
<input name='topic' class="form-control" type="text" placeholder="Topic">
<div class="form-group">
    <label for="exampleFormControlTextarea1">Textarea</label>
    <textarea name='textarea' class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea>
</div>
    <input name='file' type="file" class="form-control-file" id="exampleFormControlFile1">
<input type="submit" name="submit_button" placeholder="Submit">

文本区域

请同时分享该表单。您在哪里找到该代码的?太可怕了。它甚至不检查
$\u FILES
中的上传结果代码,并假设
移动上传的\u file()
会引发异常。您是否有php图像或文件上传的序列?