【问题标题】:PHP - How to check a subfolder for a single file?PHP - 如何检查单个文件的子文件夹?
【发布时间】:2011-10-12 11:21:41
【问题描述】:
    $code="524";
    $filepath="/assets/$code/";
    $file="";
    if(@fopen($path,"r")){

        // code
// replace function here (ill do this)

    }

echo '<a href="link.php?go=$file">your colour is: </a>';
  • /assets/542
  • /assets/542_blush/
  • /assets/542_blush/542_blush.jpg

目前,代码总是 3 位数,它总是有一个只有下划线和颜色的子文件夹,然后在那个文件中..

【问题讨论】:

    标签: php file-exists


    【解决方案1】:

    PHP 有一个file_exists() 函数;

    if ( file_exists( '/assets/' . $code . '_blush/' . $code . '_blush.jpg' ) ) {
        // ...
    }
    

    【讨论】:

    • 我不能在 URL 上使用 file_exists,所以我使用 fopen 和 @fopen 进行我自己的错误使用 - 问题是,子文件夹可能不是 _blush,它可能被读取或绿色,它始终是 123,然后是 123_color,然后是子内的 123_color.jpg。
    猜你喜欢
    • 2017-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多