dyjh 6 anni fa
parent
commit
4fbca61f35
1 ha cambiato i file con 24 aggiunte e 1 eliminazioni
  1. 24 1
      app/Helper/functions.inc.php

+ 24 - 1
app/Helper/functions.inc.php

xqd
@@ -28,7 +28,30 @@ if (! function_exists('array_unique_two_dimensional')) {
     }
 }
 
-
+if (! function_exists('getUrlImage')) {
+    /**
+     * Get the image in the url.
+     *
+     * @param  string  $img
+     * @param  string  $filename
+     * @return string|boolean
+     */
+    function getUrlImage($url, $filename)
+    {
+        if (empty($url) || empty($filename)) {
+            return false;
+        }
+        ob_start();//打开输出
+        readfile($url);//输出图片文件
+        $img = ob_get_contents();//得到浏览器输出
+        ob_end_clean();//清除输出并关闭
+      //  $size = strlen($img);//得到图片大小
+        $fp2 = @fopen($filename, "a");
+        fwrite($fp2, $img);//向当前目录写入图片文件,并重新命名
+        fclose($fp2);
+        return $filename;
+    }
+}
 
 if( ! function_exists('array_to_sort')) {
     /**