getobj.php代码<?php
header('Content-Type: image/jpg');readfile($file);
?>调用页面main.php<img src='getobj.php?file=xx1.jpg' />
<img src='getobj.php?file=xx2.jpg' />如果我多次调用main.php,并且里面有很多这样显示的图片的话,第二个main.php必须等第一个main.php的图片显示完了才会开始显示.
请问是为什么啊,有没有什么办法让他们都能一起显示.

解决方案 »

  1.   

    是不是realfile对图片文件加锁了?
      

  2.   

    是不是readfile一次就只能读取一个文件啊
      

  3.   

    顺序执行。。第一个main读取完 返回读入的字节数 在执行第二个main
      

  4.   

    不是因为readfile加锁,是因为HTML载入页面是顺序执行的。如果你想同时加载图片的话,用Ajax的异步方式向服务器提交获取图片的请求,类似下面的代码;<script type="text/javascript">
    var xmlhttp;
    function loadXMLDoc(picName){
    if (window.XMLHttpRequest){
      xmlhttp = new XMLHttpRequest();
    }
    if (window.ActiveXObject){
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (xmlhttp==null){
      alert ("Your browser does not support XMLHTTP!");
      return;
    }
    xmlhttp.onreadystatechange=displayPicture;
    xmlhttp.open("GET",'getobj.php?file=' + picName,true);
    xmlhttp.send(null);
    }function displayPicture(){
    if (xmlhttp.readyState==4){
    if (xmlhttp.status==200){
    var img = document.getElementById('img1');
    img.src = xmlhttp.responseText;
    }else{
    alert("Problem retrieving XML data:" + xmlhttp.statusText);
    }
    }
    }
    </script>
      

  5.   

    直接连到图片可能无法显示啊,因为GFW把图片封了,而我的服务器是美国的.readfile的方法就可以显示图片.
    我的服务器可能不支持ajax,还有没有别的办法?
      

  6.   

    加个遮罩层,html节点load完再全部显示,用户体验会好点.
      

  7.   

    服务器不支持ajax  还是第一次听说。
      

  8.   

    Windows 系统? 限了连接数! o_o
      

  9.   

    Ajax不需要服务器装东西,主流浏览器都支持。
      

  10.   

    ajax跟服务器哪里会有直接关系。。
      

  11.   

    头一次听说服务器还要支持ajax