How to create a soft link in PHP (code)

不言
Release: 2023-04-03 15:22:01
Original
4472 people have browsed it

This article introduces to you how to create a soft connection (code) in PHP. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. .
When accessing files outside the www directory on the server, you can use the method of creating soft links

function newSymlink($path){
    $manual = $path;  // 原路径
    $manualLink = './uploadSymlink/'.date('Y-m-d H:i:s');   // 软连接路径
    $isExistFile = true;    // 原文件是否存在的标识
   if(is_file($manual) && !is_file($manualLink)){  // 原文件存在且软连接不存在时,创建软连接
      symlink($manual, $manualLink);              // 创建软连接
    }
   if(!is_file($manualLink))  {
       $isExistFile = false;
     }elseif(!is_file($manual)){ // 原文件不存在时
       $isExistFile = false;
    }
     return array('isExistFile'=>$isExistFile,'manual'=>$manualLink);
}
Copy after login

Just use $manualLink directly in the page

Recommended related articles:

Performance optimization tool in PHP: Detailed explanation of the PHP generator

How to use curl to receive the POST address and create an interface in PHP

The above is the detailed content of How to create a soft link in PHP (code). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!