{"id":2320,"date":"2023-12-21T14:00:37","date_gmt":"2023-12-21T05:00:37","guid":{"rendered":"https:\/\/www.dogrow.net\/hp\/?p=2320"},"modified":"2023-12-24T12:38:01","modified_gmt":"2023-12-24T03:38:01","slug":"blog147","status":"publish","type":"post","link":"https:\/\/www.dogrow.net\/hp\/blog147\/","title":{"rendered":"(147) \u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u306e2\u30d1\u30bf\u30fc\u30f3"},"content":{"rendered":"<h1 class=\"my_h\">1. \u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>Web\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u30b5\u30fc\u30d0\u30fc\u5074\u306b\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u305f\u3044\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\uff12\u30d1\u30bf\u30fc\u30f3\u3067\u5b9f\u73fe\u3057\u305f\u3044\u3002<\/p>\n<p>\u30d1\u30bf\u30fc\u30f31\uff1a \u4e00\u5ea6\u306e\u30dc\u30bf\u30f3\u62bc\u4e0b\u3067\u3001\u9078\u629e\u753b\u50cf\u3092\u30b5\u30fc\u30d0\u30fc\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u5b8c\u4e86\u3055\u305b\u308b\u3002<br \/>\n\u300c\u753b\u50cf\u9078\u629e\u753b\u9762\u300d\u2192\u300c\u753b\u50cf\u6295\u7a3f\u753b\u9762\u300d<\/p>\n<p>\u30d1\u30bf\u30fc\u30f32\uff1a[\u9001\u4fe1]\u3001[\u6295\u7a3f\u78ba\u8a8d]\u306e\u4e8c\u5ea6\u306e\u30dc\u30bf\u30f3\u62bc\u4e0b\u3067\u3001\u9078\u629e\u753b\u50cf\u3092\u30b5\u30fc\u30d0\u30fc\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u5b8c\u4e86\u3055\u305b\u308b\u3002<br \/>\n\u300c\u753b\u50cf\u9078\u629e\u753b\u9762\u300d\u2192\u300c\u753b\u50cf\u78ba\u8a8d\u753b\u9762\u300d\u2192\u300c\u753b\u50cf\u6295\u7a3f\u753b\u9762\u300d<\/p>\n<h1 class=\"my_h\">2. \u3084\u3063\u3066\u307f\u308b\uff1a\u30d1\u30bf\u30fc\u30f31\u300c\u753b\u50cf\u9078\u629e\u753b\u9762\u300d\u2192\u300c\u753b\u50cf\u6295\u7a3f\u753b\u9762\u300d<\/h1>\n<h2 class=\"my_h\">1) \u30d7\u30ed\u30b0\u30e9\u30e0\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\n<h3 class=\"my_h\">(1) \u753b\u50cf\u9078\u629e\u753b\u9762\uff1aindex.html<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n  &lt;title&gt;Blog No.147-1 \u753b\u50cf\u9078\u629e\u753b\u9762&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n  &lt;form action=&quot;upload.php&quot; method=&quot;post&quot; enctype=&quot;multipart\/form-data&quot;&gt;\r\n    \u753b\u50cf\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\u3002\r\n    &lt;input type=&quot;file&quot; name=&quot;myimg&quot;&gt;&lt;br \/&gt;\r\n    &lt;input type=&quot;submit&quot; value=&quot;\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9&quot;&gt;\r\n  &lt;\/form&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h3 class=\"my_h\">(2) \u753b\u50cf\u6295\u7a3f\u753b\u9762\uff1aupload.php<\/h3>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\nrequire_once('common.php');\r\n$html_contents = '';\r\nif($_SERVER&#x5B;'REQUEST_METHOD'] == 'POST') {\r\n  \/\/ \u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u6307\u5b9a\u3042\u308a\u306e\u5834\u5408\r\n  if(isset($_FILES&#x5B;'myimg']) === true){\r\n    \/\/ \u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u30d5\u30a1\u30a4\u30eb\u306f\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\uff1f\r\n    if(true === isValidImageFile($_FILES&#x5B;'myimg'])){\r\n      \/\/ \u753b\u50cf\u4fdd\u5b58\u5148\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30d1\u30b9\u6587\u5b57\u5217\u3092\u4f5c\u6210 {top-url}\/upimg\r\n      $target_dir = '.\/upimg\/';\r\n      \/\/ \u753b\u50cf\u4fdd\u5b58\u5148\u306e\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u6587\u5b57\u5217\u3092\u4f5c\u6210\r\n      $target_file = $target_dir.basename($_FILES&#x5B;'myimg']&#x5B;'name']);\r\n      \/\/ \u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u3001\u4f5c\u6210\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u306b\u79fb\u52d5\r\n      move_uploaded_file($_FILES&#x5B;'myimg']&#x5B;'tmp_name'], $target_file);\r\n      \/\/ \u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u753b\u50cf\u306e\u8868\u793a\u7528\u306eHTML\u30bf\u30b0\u3092\u4f5c\u6210\r\n      $html_contents = '&lt;img src=&quot;'.$target_file.'&quot; \/&gt;';\r\n    }\r\n  }\r\n}\r\n?&gt;\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n  &lt;title&gt;Blog No.147-1 \u753b\u50cf\u6295\u7a3f\u753b\u9762&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;?php echo $html_contents; ?&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h3 class=\"my_h\">(4) \u5171\u901a\u95a2\u6570\u7fa4\uff1acommon.php<\/h3>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\/\/ \u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u304c\u3001\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u3002\r\n\/\/ $sgv_file : $_FILES{'xxxxx'] \u3092\u5165\u529b\u3059\u308b\u3002\r\nfunction isValidImageFile( $sgv_file ){\r\n  $ret = false;\r\n  \/\/------------------------------------------------------------------------\r\n  \/\/ check 1 : \u62e1\u5f35\u5b50\u3092\u691c\u67fb\r\n  $allowedExts = &#x5B;'jpg', 'jpeg', 'png', 'gif', 'tiff', 'tif'];\r\n  $ext = pathinfo($sgv_file&#x5B;'name'], PATHINFO_EXTENSION);   \/\/ \u30d5\u30a1\u30a4\u30eb\u540d\u6587\u5b57\u5217\u304b\u3089\u62e1\u5f35\u5b50\u3092\u53d6\u5f97\r\n  if(false === in_array(strtolower($ext), $allowedExts)){   \/\/ \u53d7\u3051\u5165\u308c\u53ef\u80fd\u306a\u62e1\u5f35\u5b50\uff1f\r\n    goto tagEND;\r\n  }\r\n  \/\/------------------------------------------------------------------------\r\n  \/\/ check 2 : MIME\u30bf\u30a4\u30d7\u3092\u691c\u67fb\r\n  $allowedMimeTypes = &#x5B;'image\/jpeg', 'image\/png', 'image\/gif', 'image\/tiff'];\r\n  $fileMimeType = mime_content_type($sgv_file&#x5B;'tmp_name']); \/\/ Upload\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u306eMIME\u30bf\u30a4\u30d7\u3092\u53d6\u5f97\r\n  if(false === in_array($fileMimeType, $allowedMimeTypes)){ \/\/ \u53d7\u3051\u5165\u308c\u53ef\u80fd\u306aMIME\u30bf\u30a4\u30d7\uff1f\r\n    goto tagEND;\r\n  }\r\n  \/\/------------------------------------------------------------------------\r\n  \/\/ check 3 : \u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u30d8\u30c3\u30c0\u3092\u691c\u67fb\r\n  if (false === getimagesize($sgv_file&#x5B;'tmp_name'])) {\r\n    goto tagEND;\r\n  }\r\n  \/\/------------------------------------------------------------------------\r\n  \/\/ \u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u3067\u3042\u308b\u3068\u78ba\u8a8d\u3057\u305f\u3002\r\n  $ret = true;\r\n\r\ntagEND:\r\n  return $ret;\r\n}\r\n<\/pre>\n<h1 class=\"my_h\">3. \u3084\u3063\u3066\u307f\u308b\uff1a\u30d1\u30bf\u30fc\u30f32\u300c\u753b\u50cf\u9078\u629e\u753b\u9762\u300d\u2192\u300c\u753b\u50cf\u78ba\u8a8d\u753b\u9762\u300d\u2192\u300c\u753b\u50cf\u6295\u7a3f\u753b\u9762\u300d<\/h1>\n<h2 class=\"my_h\">1) \u51e6\u7406\u306e\u6d41\u308c<\/h2>\n<h2 class=\"my_h\">2) \u30d7\u30ed\u30b0\u30e9\u30e0\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\n<h3 class=\"my_h\">(1) \u753b\u50cf\u9078\u629e\u753b\u9762\uff1aindex.html<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n  &lt;title&gt;Blog No.147-2 \u753b\u50cf\u9078\u629e\u753b\u9762&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n  &lt;form action=&quot;confirm.php&quot; method=&quot;post&quot; enctype=&quot;multipart\/form-data&quot;&gt;\r\n    \u753b\u50cf\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\u3002\r\n    &lt;input type=&quot;file&quot; name=&quot;myimg&quot;&gt;&lt;br \/&gt;\r\n    &lt;input type=&quot;submit&quot; value=&quot;\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9&quot;&gt;\r\n  &lt;\/form&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h3 class=\"my_h\">(2) \u753b\u50cf\u78ba\u8a8d\u753b\u9762\uff1aconfirm.php<\/h3>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\nsession_start();\r\nrequire_once('common.php');\r\n$html_confirm = '';\r\nif($_SERVER&#x5B;'REQUEST_METHOD'] == 'POST') {\r\n  \/\/ \u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u6307\u5b9a\u3042\u308a\u306e\u5834\u5408\r\n  if(isset($_FILES&#x5B;'myimg']) === true){\r\n    \/\/ \u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u30d5\u30a1\u30a4\u30eb\u306f\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\uff1f\r\n    if(true === isValidImageFile($_FILES&#x5B;'myimg'])){\r\n      \/\/ \u4e00\u6642\u753b\u50cf\u4fdd\u5b58\u5148\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30d1\u30b9\u6587\u5b57\u5217\u3092\u4f5c\u6210 .\/tmpimg\r\n      $target_dir = '.\/tmpimg\/';\r\n      \/\/ \u753b\u50cf\u4fdd\u5b58\u5148\u306e\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u6587\u5b57\u5217\u3092\u4f5c\u6210\r\n      $fnameNew = makeUniqueFileName($_FILES&#x5B;'myimg']&#x5B;'name']);\r\n      $target_file = $target_dir.$fnameNew;\r\n      \/\/ \u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u3001\u4f5c\u6210\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u306b\u79fb\u52d5\r\n      move_uploaded_file($_FILES&#x5B;'myimg']&#x5B;'tmp_name'], $target_file);\r\n      \/\/ \u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\u6587\u5b57\u5217\u3092\u30bb\u30c3\u30b7\u30e7\u30f3\u306b\u4fdd\u5b58\r\n      $_SESSION&#x5B;'temp_uploaded_img'] = $target_file;\r\n      \/\/ \u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u753b\u50cf\u306e\u8868\u793a\u7528\u306eHTML\u30bf\u30b0\u3092\u4f5c\u6210\r\n$html_contents = &lt;&lt;&lt; EOM\r\n&lt;form action=&quot;upload.php&quot; method=&quot;post&quot;&gt;\r\n  &lt;img src=&quot;{$target_file}&quot; \/&gt;\r\n  &lt;input type=&quot;submit&quot; value=&quot;\u3053\u306e\u753b\u50cf\u3092\u6295\u7a3f\u3057\u307e\u3059\u3002&quot;&gt;\r\n&lt;\/form&gt;\r\nEOM;\r\n    }\r\n  }\r\n}\r\n?&gt;\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n  &lt;title&gt;Blog No.147-2 \u753b\u50cf\u78ba\u8a8d\u753b\u9762&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;?php echo html_confirm; ?&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h3 class=\"my_h\">(3) \u753b\u50cf\u6295\u7a3f\u753b\u9762\uff1aupload.php<\/h3>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\nsession_start();\r\nrequire_once('common.php');\r\n$html_imgshow = '';\r\n\r\n\/\/ \u30bb\u30c3\u30b7\u30e7\u30f3\u304b\u3089\u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\u6587\u5b57\u5217\u3092\u53d6\u5f97\r\n$temp_uploaded_img = $_SESSION&#x5B;'temp_uploaded_img'];\r\n\/\/ \u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3057\u306a\u3044\uff1f \u2192 \u4e0d\u6b63\u64cd\u4f5c\u3068\u5224\u65ad\u3059\u308b\u3002\r\nif(file_exists($temp_uploaded_img) === false){\r\n  echo '\u4e0d\u6b63\u306a\u64cd\u4f5c\u3067\u3059\u3002'; exit();\r\n}\r\n\r\n\/\/ \u30d5\u30a1\u30a4\u30eb\u306e\u62e1\u5f35\u5b50\u3092\u53d6\u5f97\r\n$ext = pathinfo($temp_uploaded_img, PATHINFO_EXTENSION);\r\n\/\/ \u30d5\u30a1\u30a4\u30eb\u3092\u79fb\u52d5\u5f8c\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u4f5c\u6210\r\n$fnameNew = makeImgFileNameBodyWithId(time(), $ext);\r\n\r\n\/\/ \u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u3092\u6b63\u5f0f\u306b\u753b\u50cf\u4fdd\u5b58\u30d5\u30a9\u30eb\u30c0\u306b\u79fb\u52d5\u3059\u308b\u3002\r\n$target_file = '.\/upimg\/'.$fnameNew;\r\nrename($temp_uploaded_img, $target_file);\r\n\r\n\/\/ \u3054\u307f\u51e6\u7406\uff081\u6642\u9593\u4ee5\u4e0a\u524d\u306b\u4f5c\u3089\u308c\u305f\u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664\uff09\r\nremoveOldFiles('.\/tmpimg\/');\r\n\r\n\/\/ \u6295\u7a3f\u753b\u50cf\u306e\u8868\u793a\u7528\u306eHTML\u30bf\u30b0\u3092\u4f5c\u6210\r\n$html_imgshow = &lt;&lt;&lt; EOM\r\n&lt;img src=&quot;{$target_file}&quot;&gt;&lt;br \/&gt;\r\n\u3053\u306e\u753b\u50cf\u306e\u6295\u7a3f\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\uff01\r\nEOM;\r\n?&gt;\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n  &lt;title&gt;Blog No.147-2 \u753b\u50cf\u6295\u7a3f\u753b\u9762&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;?php echo $html_imgshow; ?&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h3 class=\"my_h\">(4) \u5171\u901a\u95a2\u6570\u7fa4\uff1acommon.php<\/h3>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\/\/ \u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u304c\u3001\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u3002\r\n\/\/ $sgv_file : $_FILES{'xxxxx'] \u3092\u5165\u529b\u3059\u308b\u3002\r\nfunction isValidImageFile( $sgv_file ){\r\n  $ret = false;\r\n\r\n  \/\/ check 1 : \u62e1\u5f35\u5b50\u3092\u691c\u67fb\r\n  $allowedExts = &#x5B;'jpg', 'jpeg', 'png', 'gif', 'tiff', 'tif'];\r\n  $ext = pathinfo($sgv_file&#x5B;'name'], PATHINFO_EXTENSION);   \/\/ \u30d5\u30a1\u30a4\u30eb\u540d\u6587\u5b57\u5217\u304b\u3089\u62e1\u5f35\u5b50\u3092\u53d6\u5f97\r\n  if(false === in_array(strtolower($ext), $allowedExts)){   \/\/ \u53d7\u3051\u5165\u308c\u53ef\u80fd\u306a\u62e1\u5f35\u5b50\uff1f\r\n    goto tagEND;\r\n  }\r\n  \/\/ check 2 : MIME\u30bf\u30a4\u30d7\u3092\u691c\u67fb\r\n  $allowedMimeTypes = &#x5B;'image\/jpeg', 'image\/png', 'image\/gif', 'image\/tiff'];\r\n  $fileMimeType = mime_content_type($sgv_file&#x5B;'tmp_name']); \/\/ Upload\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u306eMIME\u30bf\u30a4\u30d7\u3092\u53d6\u5f97\r\n  if(false === in_array($fileMimeType, $allowedMimeTypes)){ \/\/ \u53d7\u3051\u5165\u308c\u53ef\u80fd\u306aMIME\u30bf\u30a4\u30d7\uff1f\r\n    goto tagEND;\r\n  }\r\n  \/\/ check 3 : \u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u30d8\u30c3\u30c0\u3092\u691c\u67fb\r\n  if (false === getimagesize($sgv_file&#x5B;'tmp_name'])) {\r\n    goto tagEND;\r\n  }\r\n  \/\/ \u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u3067\u3042\u308b\u3068\u78ba\u8a8d\u3057\u305f\u3002\r\n  $ret = true;\r\n\r\ntagEND:\r\n  return $ret;\r\n}\r\n\r\n\/\/ \u30bb\u30c3\u30b7\u30e7\u30f3ID\u3068\u6642\u523b\u304b\u3089\u30e6\u30cb\u30fc\u30af\u306a\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u4f5c\u6210\u3059\u308b\u3002\r\nfunction makeUniqueFileName( $fname ){\r\n  $ssid = session_id();\r\n  $time = time();\r\n  return $ssid.$time.basename($fname);\r\n}\r\n\r\n\/\/ \u6307\u5b9aID\u3067\u30d5\u30a1\u30a4\u30eb\u540d\u6587\u5b57\u5217\u3092\u4f5c\u6210\u3059\u308b\u3002\r\n\/\/ $ext : \u62e1\u5f35\u5b50\u6587\u5b57\u5217 \u4f8b) jpg png gif (\u203b.(dot)\u7121\u3057\u3067\u6307\u5b9a\u3059\u308b\u3053\u3068)\r\nfunction makeImgFileNameBodyWithId( $id, $ext='' ){\r\n  if($ext != ''){\r\n    $ext = '.'.$ext;\r\n  }\r\n  return 'img_uploaded_'.$id.$ext;\r\n}\r\n\r\n\/\/ \u6307\u5b9aID\u306b\u5bfe\u5fdc\u3059\u308b\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u3092\u63a2\u3059\u3002\r\nfunction findImgFileNakeById( $id, $withPath=false ){\r\n  $ret = '';\r\n  $dir = '.\/upimg';\r\n  $ptn = '\/img_uploaded_'.$id.'*';\r\n  \/\/ \u6307\u5b9a\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u3067\u3001\u6307\u5b9a\u30d1\u30bf\u30fc\u30f3\u306b\u30de\u30c3\u30c1\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u3092\u63a2\u3059\u3002\r\n  $ary_files = glob($dir.$ptn);\r\n  if(is_array($ary_files) === true){        \/\/ \u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3057\u305f\uff1f\r\n    if($withPath === true){\r\n      $ret = $ary_files&#x5B;0];\r\n    }else{\r\n      $ret = basename($ary_files&#x5B;0]);\r\n    }\r\n  }\r\n  return $ret;\r\n}\r\n\r\n\/\/ \u53e4\u3044\u4e00\u6642\u4fdd\u5b58\u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664\u3059\u308b\u3002\r\n\/\/ $lifetime_sec : \u751f\u5b58\u671f\u9593&#x5B;\u79d2] (\u4f5c\u6210\u6642\u523b\u304b\u3089\u6307\u5b9a\u6642\u9593\u3060\u3051\u7d4c\u904e\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664\u3059\u308b\u3002)\r\nfunction removeOldFiles( $dir, $lifetime_sec=3600 ){\r\n  \/\/ \u6307\u5b9a\u3055\u308c\u305f\u30d5\u30a9\u30eb\u30c0\u5185\u306e\u5168\u30d5\u30a1\u30a4\u30eb\u3092\u53d6\u5f97\u3059\u308b\u3002\r\n  $ary_files = glob($dir.'\/*');\r\n  if(is_array($ary_files) === true){        \/\/ \u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3057\u305f\uff1f\r\n    foreach($ary_files as $file){           \/\/ 1\u30d5\u30a1\u30a4\u30eb\u305a\u3064\u51e6\u7406\u3059\u308b\u3002\r\n      $timemake  = filemtime($file);        \/\/ \u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210\u6642\u523b\u3092\u53d6\u5f97\r\n      $timelimit = time() - $lifetime_sec;  \/\/ \u30d5\u30a1\u30a4\u30eb\u306e\u751f\u5b58\u671f\u9650\u3092\u7b97\u51fa\r\n      if($timemake &lt; $timelimit){\r\n        unlink($file);                      \/\/ \u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664\r\n      }\r\n    }\r\n  }\r\n}\r\n?&gt;\r\n<\/pre>\n<hr class=\"my_hr_bottom\">\n","protected":false},"excerpt":{"rendered":"<p>1. \u3084\u308a\u305f\u3044\u3053\u3068 Web\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u30b5\u30fc\u30d0\u30fc\u5074\u306b\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u305f\u3044\u3002 \u4ee5\u4e0b\u306e\uff12\u30d1\u30bf\u30fc\u30f3\u3067\u5b9f\u73fe\u3057\u305f\u3044\u3002 \u30d1\u30bf\u30fc\u30f31\uff1a \u4e00\u5ea6\u306e\u30dc\u30bf\u30f3\u62bc\u4e0b\u3067\u3001\u9078\u629e\u753b\u50cf\u3092\u30b5\u30fc\u30d0\u30fc\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u5b8c\u4e86\u3055\u305b\u308b\u3002 \u300c\u753b\u50cf\u9078\u629e\u753b\u9762\u300d\u2192\u300c\u753b\u50cf\u6295\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.dogrow.net\/hp\/blog147\/\">\u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,44],"tags":[],"class_list":["post-2320","post","type-post","status-publish","format-standard","hentry","category-htmlcss","category-44"],"views":578,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/posts\/2320","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/comments?post=2320"}],"version-history":[{"count":20,"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/posts\/2320\/revisions"}],"predecessor-version":[{"id":2343,"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/posts\/2320\/revisions\/2343"}],"wp:attachment":[{"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/media?parent=2320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/categories?post=2320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/tags?post=2320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}