我这样做是为了将目录和文件上传到数据库中。
<?php
require_once('inc/config.php');
$con = mysqli_connect($host, $user, $pass, $db) or die ('Cannot connect :'.mysqli_error());
$sql = "SELECT * FROM profile_info WHERE username = '" .
$_SESSION['username'] . "'";
$result = mysqli_query($con,$sql);
$row = mysqli_fetch_array($result);
$resume_name = $row['file_name'];
$resume_location ='resume/'.$resume_name;
$resume_ok = "<a href='".$resume_location."'>Resume</a>";
?>
这会抓取简历名称,当我想将文件名与目录一起获取时,它只显示目录而不是像这样的文件名
localhost:82/resume
而不是像这样
localhost:82/resume/Jannan.pdf
可能出现什么问题?
答案 0 :(得分:0)
在变量中设置SITE URL并给出href
目录的完整路径 <?php
require_once('inc/config.php');
$con = mysqli_connect($host, $user, $pass, $db) or die ('Cannot connect :'.mysqli_error());
$SITE_URL = "http://localhost:82/";
$sql = "SELECT * FROM profile_info WHERE username = '" . $_SESSION['username'] . "'";
$result = mysqli_query($con,$sql);
$row = mysqli_fetch_array($result);
$resume_name = $row['file_name'];
$resume_location = $SITE_URL.'resume/'.$resume_name;
$resume_ok = "<a href='".$resume_location."'>Resume</a>";
?>