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); }
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!