Snippets

Alexey ilyaskin Download image function

Updated by Alexey ilyaskin

File snippet.php Modified

  • Ignore whitespace
  • Hide word diff
+<?php
 function downloadImage($source, $targetPath) {
 	$imageFile = file_get_contents($source);
 	$imageName = basename($source);
Updated by Alexey ilyaskin

File snippet.php Modified

  • Ignore whitespace
  • Hide word diff
 	$imageFile = file_get_contents($source);
 	$imageName = basename($source);
 	// русские имена файлов
-	$imageName = mb_convert_encoding($imageName,"windows-1251","UTF-8");
+	$imageName = mb_convert_encoding($imageName, 'windows-1251', 'UTF-8');
 	$imageTarget = $targetPath . '/' . $imageName;
 	file_put_contents($imageTarget, $imageFile);
 	if (file_exists($imageTarget) && filesize($imageTarget) > 0) {
Updated by Alexey ilyaskin

File Download image function Deleted

  • Ignore whitespace
  • Hide word diff
-function downloadImage($source, $targetPath) {
-	$imageFile = file_get_contents($source);
-	$imageName = basename($source);
-	// русские имена файлов
-	$imageName = mb_convert_encoding($imageName,"windows-1251","UTF-8");
-	$imageTarget = $targetPath . '/' . $imageName;
-	file_put_contents($imageTarget, $imageFile);
-	if (file_exists($imageTarget) && filesize($imageTarget) > 0) {
-		return $imageTarget;
-	}
-	return false;
-}

File snippet.php Added

  • Ignore whitespace
  • Hide word diff
+function downloadImage($source, $targetPath) {
+	$imageFile = file_get_contents($source);
+	$imageName = basename($source);
+	// русские имена файлов
+	$imageName = mb_convert_encoding($imageName,"windows-1251","UTF-8");
+	$imageTarget = $targetPath . '/' . $imageName;
+	file_put_contents($imageTarget, $imageFile);
+	if (file_exists($imageTarget) && filesize($imageTarget) > 0) {
+		return $imageTarget;
+	}
+	return false;
+}
Created by Alexey ilyaskin

File Download image function Added

  • Ignore whitespace
  • Hide word diff
+function downloadImage($source, $targetPath) {
+	$imageFile = file_get_contents($source);
+	$imageName = basename($source);
+	// русские имена файлов
+	$imageName = mb_convert_encoding($imageName,"windows-1251","UTF-8");
+	$imageTarget = $targetPath . '/' . $imageName;
+	file_put_contents($imageTarget, $imageFile);
+	if (file_exists($imageTarget) && filesize($imageTarget) > 0) {
+		return $imageTarget;
+	}
+	return false;
+}
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.