0

我在浏览器中可以正常工作,但适用于 ios 的空气需要完整地址。

<?php $path_to_image_dir = 'Games/game_images/'.$username; 

    $xml_string = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><data> <LoaderMax name=\"gallery\">";

    if ( $handle = opendir( $path_to_image_dir ) ) {
        $i = 1;
        while (false !== ($file = readdir($handle))) {
            if ( is_file($path_to_image_dir.'/'.$file) ) {
                $xml_string .= "<ImageLoader url=\"" . $path_to_image_dir."/".$file . "\"  />";
            }
        }
        closedir($handle);
    }


$xml_string .= "</LoaderMax></data>";
$ignore = array('.','..','cgi-bin','.DS_Store');
$file = fopen($username.'_imagesfile.xml','w');
fwrite($file, $xml_string);
fclose($file);
?>

这是 xml 结果:

<?xml version="1.0" encoding="iso-8859-1"?><data> <LoaderMax name="gallery"><ImageLoader url="Games/game_images/mrpeepers/1365535674.jpg"  /><ImageLoader url="Games/game_images/mrpeepers/1365535527.jpg"  /></LoaderMax></data>

如果地址是手动添加的,则适用于 ioshttp://wwww.mysite.ccom/Games/game_images/mrpeeper/1365535674.jpg

4

1 回答 1

1

将 $_SERVER['SERVER_NAME'] 添加到您的目录名称中,如下所示:

$xml_string .= "<ImageLoader url=\"" . $_SERVER['SERVER_NAME'] . "/" . $path_to_image_dir."/".$file . "\"  />";

http://php.net/manual/en/reserved.variables.server.php

于 2013-04-09T23:42:14.450 回答