文件上传到mysql

时间:2019-05-13 13:14:20

标签: php mysql

我正在尝试在mysql数据库中上传文件,但不会 它只会显示“未上传” ps:我没有收到任何错误或警告

<?php

if(isset($_POST['btn'])){
   $file= addslashes($_FILES['file']['tmp_name']);
   $name= addslashes($_FILES['file']['name']);
   $file= file_get_contents($file);
   $file=base64_encode($file);
   savefile($name,$file);
}

   function savefile($name,$file)
   {
       $con= mysqli_connect ("localhost", "root", "");
       mysqli_select_db($con,"testapp");
       $qry= "insert into testapp (file name,file) values 
('$name','$file')";
       $result= mysqli_query($con, $qry);
       if($result){
           echo "<br/>file uploaded.";
       }
       else{
           echo "<br/>file not uploaded";
       }
   }


     ?>

0 个答案:

没有答案