ThinkPHP部署到不支持修改服务器配置文件的服务器上
以 Thinkphp 6 为例:
1、拷贝 public/index.php、public/router.php、public/.htaccess等文件到项目根目录下;
2、将index.php文件第15行 require __DIR__ . '/../vendor/autoload.php'; 修改为 require __DIR__ . '/vendor/autoload.php';;
3、将所有涉及上传文件的返回路径加上/public,例如:
public function uploadFile()
{
$file = FacadeRequest::file('file');
$savename = '/public/storage/' .
\think\facade\Filesystem::disk('public')->putFile('page', $file);
return json([
'errno' => 0,
'msg' => '',
'data' => [
$savename,
],
]);
}