如果我使用PHP文件作爲源圖像,其中:IMG PHP的src異步
$file = $_GET["file"];
$file_get = get_file_contents("from/".$file);
$fopen = fopen("to/".$file,"w+");
fwrite($fopen, $file_get);
fclose($fopen);
header("Location:to/".$file);
而且如果我在一個頁面上使用的那種很多圖片,如:
<img src="image.php/?file=img.jpg>
<img src="image.php/?file=img2.jpg>
<img src="image.php/?file=img3.jpg>
...
我發現image.php中的代碼不會異步運行。圖像被逐一下載。我怎樣才能避免它?
會話只能由一個請求中同時被打開,所有其他請求將坐下來等待。儘快關閉會話以允許其他請求並行處理。 – Sammitch
你想達到什麼目的? – Xatenev
它也可能是內存使用瓶頸...... get_file_contents可能會將整個映像讀入內存。也許做一個[複製](http://php.net/manual/en/function.copy.php)會更合適 – Orangepill