doumaogui5937 2018-10-27 09:33 采纳率: 100%
浏览 47
已采纳

使用PHP将文件上传到Mysql中,但不会在DB上显示[重复]

This question already has an answer here:

I am using Mysql DB to upload a PDF file in but the PDF file is not written in DB as in picture enter image description here

<?php 
//include the PDF files inside the DB

if (isset($_POST['reg_user'])) {

$arq = $_FILES['pdf_upload']['name'];
$arq = str_replace(" ", "_", $arq);

$target = "pdf/";
$yes = "yes";
$fileTarget = $target.$arq;
$tempFileName = $_FILES["pdf_upload"]["tmp_name"];

//$allow=array('pdf');
//$temp=explode(".",$arq);
//$extension=end($temp);
$digits = 3;
$random = rand(pow(10, $digits-1), pow(10, $digits)-1);

move_uploaded_file($tempFileName,$fileTarget);
//$qry = mysqli_query($db,"INSERT INTO 'pp_seeker_resumes'(file_name)VALUES('$arq');");
if($result) { 
  header('location: success.php');  
  $qry = "INSERT INTO pp_seeker_resumes(seeker_ID,is_uploaded_resume,file_name)VALUES('$random','$yes','$arq');";
  $db->query($qry) or die("Error : ".mysqli_error($db));      
}
else {      
  echo "Sorry !!! There was an error in uploading your file";     
}
//mysqli_close($db);
/*if($qry){
  echo "PDF File upload success";
}else{
  echo "upload Error !! ";
}*/
}
?>

Here $db is the connection I have made in server.php ,It works fine. This is the HTML form part

<label style="margin:12px">Upload CV(.pdf)</label> <input type="file" class="form-control" name="pdf_upload" id="fileHelp" aria-describedby="fileHelp" accept="application/pdf"> here success.php is the page loaded after form filling. Thankyou for your help.

</div>
  • 写回答

1条回答 默认 最新

  • dtnpf35197 2018-10-27 09:49
    关注

    Thanks to cloudinary documentation,I found the reason this should be added to the form in HTML

    enctype="multipart/form-data"
    

    without this file upload is not possible with post method,thus this should be done

    <form method = "post" action="member_form1.php"  enctype="multipart/form-data">
    <label style="margin:12px">Upload CV(.pdf)</label>
          <input type="file" class="form-control" name="pdf_upload" 
         id="fileHelp" aria-describedby="fileHelp" accept="application/pdf">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类