其中img文件夾里面有5張jpg圖片,
random r = new random();
string path = "img/"+r.next(1,5)+".jpg";
//輸出格式
response.contenttype = "image/jpeg";
//輸出文件
response.writefile(path);
response.end();
復雜點的話可以遍歷某個文件夾里面的所有文件名.....
不懂的話看看asp版本的找點靈感
asp版本的
<%
randomize
dim url,total
total=10 '圖片總數(shù)
url="images/pic"&((int(rnd()*100000) mod total) +1)&".jpg"
'eg:
'url="images/pic1.jpg"
'url="images/pic8.jpg"
'.........
%>
<img src="<%=url%>"/>
簡單了點...
新聞熱點
疑難解答
圖片精選