PHP ÆÄÀÏ Á¸Àç ¿©ºÎ ÆľÇÇϱâ(·ÎÄà ÆÄÀÏ Á¸Àç ¹× ¿ø°ÝÁö ÆÄÀÏ Á¸Àç) |
|
|
 |
3³â Àü |
1. ·ÎÄü¹ö¿¡¼ ÆÄÀÏÁ¸ÀçÇÏ´ÂÁö È®ÀÎ
<?
$local_file_name = "./img/ÆÄÀϸí.png";
function localFileExist($filepath) {
if(file_exists($filepath)) {
return true;
} else {
return false;
}
}
?>
<? if(localFileExist($local_file_name) == 1) { ?>
ÆÄÀÏÀÌ Á¸ÀçÇÕ´Ï´Ù.
<? } else { ?>
ÆÄÀÏÀÌ Á¸Àç ÇÏÁö ¾Ê½À´Ï´Ù.
<? } ?>
2. ¿ø°ÝÁö¿¡ ÆÄÀÏÀÌ Á¸ÀçÇÏ´ÂÁö È®ÀÎ
<?
$remot_file_name = "http://¿ø°ÝÁö URL/ÆÄÀϸí.png";
function remoteFileExist($filepath) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$filepath);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if(curl_exec($ch)!==false) {
return true;
} else {
return false;
}
}
?>
<? if(remoteFileExist($remot_file_name) == 1) { ?>
¿ø°ÝÁö¿¡ ÆÄÀÏÀÌ Á¸ÀçÇÕ´Ï´Ù.
<? } else { ?>
¿ø°ÝÁö¿¡ ÆÄÀÏÀÌ Á¸Àç ÇÏÁö ¾Ê½À´Ï´Ù.
<? } ?> |
|
̵̧ : 180 |
̵̧
¸ñ·Ï
|
|