防盗链需要,很多文件我们是不公开给客户看到真实的url的,用php的get参数带一个参数过去由php处理。- ) W. m0 N5 l! t: ]7 F
- $fileURL=;
9 K- U8 o! a6 d( T } - + a0 ~; h6 e! @0 m- c) O
- $filename=;
, M; \! ?5 `5 x7 d# {3 V) B - 8 l/ c& b$ S2 y2 K' r
- $file = @ fopen($fileURL,"r"); " r" A$ T; R9 ]+ P$ \
- if (!$file) {
1 w: |- |+ U+ A8 Q E+ Y0 A# ` - echo "文件找不到";
0 F9 X1 B* r2 a9 w, `; {2 _- Q - } else {
9 J9 J: q8 K' Q0 r% {& V) v - Header("Content-type: application/octet-stream"); , ?1 x( _% Z* v. }, R
- Header("Content-Disposition: attachment; filename=" . $filename); - l7 R7 q0 }1 [0 l
- while (!feof ($file)) { ' _3 \. d/ H! E
- echo fread($file,50000);
# I' h9 H2 W- d8 U1 z, H - }
3 Q- y0 n2 Y8 S7 F8 M1 W6 G6 H - fclose (file); : F9 j3 u, w' q/ ^! o1 B
- }
1 l9 d- A+ h; {2 T
Copy |
|