PHP没有获得文件的完整路径

时间:2017-07-13 12:11:00

标签: php mysql

我这样做是为了将目录和文件上传到数据库中。

<?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可能出现什么问题?

1 个答案:

答案 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>";

    ?>