我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

PHP is_file和服务器根相对路径

How can I use is_file with a path like: /folder/file.jpg please?

Thank you!

If the path starts with a / this means the path is absolute. When the path is relative (ie not starting with /) then the path relative to the php script is taken. If you want to have /folder/file.jpg relative to the server root, you can append the root.

$path = $_SERVER['DOCUMENT_ROOT'] . '/folder/file.jpg';

Use $_SERVER['DOCUMENT_ROOT']:

$is_file = is_file($_SERVER['DOCUMENT_ROOT'] . '/folder/file.jpg');

近期文章

  • 请教ks匿名直播间的eid是假的如何破?
  • 我的eclipse突然打不开了呢
  • 抖音设置隐私观众席点开,能点开客户聊天界面
  • java 和ajax get请求
  • java无法实现类功能的跳转
  • 本人想不明白了 助一下吧
  • 为什么这个传址会出现这样的错误
  • excel vba 入门 计算1-100的乘积
  • 笔记本重装系统后一直进入bios
  • PHP数组访问数组对象的标题名称
  • python脚本问题.
  • 大量重绘窗口时,如何避免 Win32 控件闪烁?
  • 如何在登录界面切换用户window11系统
  • java报错Cannot parse null string
  • 芯片制造转后端设计可行吗?需要读研或参加培训班吗?
  • 数组传入函数后不能正确利用sizeof(arr)/ sizeof (arr[0]) 计算长度
  • 安装cnpm,出现以下图片中的问题
  • c语言有关判断质数问题
  • 试图在另一个div之前移动一个div而不搞砸我不明白的PHP :)
  • 有关sql查询命令的错误

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华