<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http:
--><?php
$url
=
$_POST
[
'url'
];
DownImage(
$url
);
function
DownImage(
$url
)
{
$mime
=getMime(
$url
);
header(
"Content-Type: "
.
$mime
);
$ext
=getExt(
$url
);
header(
"Content-Disposition: attachment; filename="
.
basename
(
$url
) );
header(
"Content-Transfer-Encoding: binary"
);
$fp
=file(
$url
);
foreach
(
$fp
as
$fileLine
)
{
echo
$fileLine
;
}
}
function
getMime(
$url
)
{
if
(preg_match(
"/\.(jpg|jpeg)$/"
,
$url
))
return
"image/jpeg"
;
else
if
(preg_match(
"/\.(gif)$/"
,
$url
))
return
"image/gif"
;
else
if
(preg_match(
"/\.(png)$/"
,
$url
))
return
"image/png"
;
else
if
(preg_match(
"/\.(bmp)$/"
,
$url
))
return
"image/bmp"
;
else
return
"err"
;
}
function
getExt(
$url
)
{
if
(preg_match(
"/\.(jpg|jpeg)$/"
,
$url
))
return
"jpg"
;
else
if
(preg_match(
"/\.(gif)$/"
,
$url
))
return
"gif"
;
else
if
(preg_match(
"/\.(png)$/"
,
$url
))
return
"png"
;
else
if
(preg_match(
"/\.(bmp)$/"
,
$url
))
return
"bmp"
;
else
return
"err"
;
}
?>