使用php上传文件|文件不再上传

时间:2019-03-14 15:11:48

标签: php mysql sql pdo uploading

我正在使用PHP将文件上传到数据库。一切从一开始就工作,但突然停止了工作。 这是我的代码

print "<form action='' method='POST' enctype='multipart/form-data'>";
print "<td class='tesname'>". $row['exam_name']. "</td>";
print "<input type='hidden' name='user_id' value='".$_GET['user_id']."'>";
print "<input type='hidden' name='lab_name' value='".$row['exam_name']."'>";                        
print "<td class='tesdate'><input class='form-control' type='Date' autofocus  id='TestDate' placeholder='Test Date' name='testDate'></td>";
print "<td><input type='file' class='file-input' id='myfile' placeholder='Upload' name='myfile'></td>";
print "<td><input type='hidden' name='exam_id' value='".$row['exam_id']."'>
<button type='Submit' class='btn btn-info' name='btn'>upload</button></td>
</form>

这是PHP代码

$dbh = new PDO("mysql:host=localhost;dbname=ehr_new","root", "");

if(isset($_POST['btn'])){
    $name = $_FILES['myfile']['name'];
    $type = $_FILES['myfile']['type'];
    $data = file_get_contents($_FILES['myfile']['tmp_name']);
    $stmt = $dbh->prepare("insert into patinet_examination values(?,?,?,?,?,?,?)");
    $stmt->bindParam(1,$_POST['testDate']);
    $stmt->bindParam(2,$_POST['exam_id']);
    $stmt->bindParam(3,$_POST['user_id']);
    $stmt->bindParam(4,$_POST['lab_name']);
    $stmt->bindParam(5,$name);
    $stmt->bindParam(6,$type);
    $stmt->bindParam(7,$data);
    $stmt->execute();
    print "success";
}

正如我所说的,一切工作正常,突然查询被拒绝插入数据库。

另外,这是我的数据库结构

 db structure

谢谢

0 个答案:

没有答案