doucuo4413 2019-03-14 15:11
浏览 40

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

I am uploading files to my database using PHP. Everything was working in the beginning, but it suddenly stopped working. here is my code

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>

and here is the PHP code

$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";
}

as i said everything was working fine, and suddenly the query is refusing to insert to the database.

also, here is my db structure

db structure

Thank you

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测