Search
 
SCRIPT & CODE EXAMPLE
 

PHP

save an image use php

<?php
// Image URL
$url = 'https://www.example.com/test.png';
 
// Image path
$img = '../images/test.png';
 
// Save image
file_put_contents($img, file_get_contents($url));
?>
Comment

saving an image from pc to php

<?php
  
$url = 
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-6-1.png'; 
  
$img = 'logo.png'; 
  
// Function to write image into file
file_put_contents($img, file_get_contents($url));
  
echo "File downloaded!"
  
?>
Comment

save data as image php

$data = 'data:image/png;base64,AAAFBfj42Pj4';

list($type, $data) = explode(';', $data);
list(, $data)      = explode(',', $data);
$data = base64_decode($data);

file_put_contents('/tmp/image.png', $data);
Comment

saving an image from pc to php

<?php
  
function file_get_contents_curl($url) {
    $ch = curl_init();
  
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
  
    $data = curl_exec($ch);
    curl_close($ch);
  
    return $data;
}
  
$data = file_get_contents_curl(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-6-1.png');
  
$fp = 'logo-1.png';
  
file_put_contents( $fp, $data );
echo "File downloaded!"
  
?>
Comment

PREVIOUS NEXT
Code Example
Php :: get array key based on value php 
Php :: join in laravel eloquent 
Php :: phpcs ignore line warning 
Php :: install php-8 
Php :: --prefer-dist what is use in laravel 
Php :: php date first day of month and last month 
Php :: php text to html 
Php :: how to limit word in php 
Php :: turn off deprecated warnings php 
Php :: php get second last element of array 
Php :: how to get a whole number from decimal in php 
Php :: validate user password laravel8 
Php :: from user id to user role wordpress 
Php :: how to call a helper function in blade 
Php :: reload page laravel 
Php :: remove text keep numbers only php 
Php :: php return json data 
Php :: Theme and plugin editor in wp dashboard missing 
Php :: codeigniter 3 or where not in 
Php :: unset by key name php 
Php :: types of controller in laravel 
Php :: fnmatch php ignore case 
Php :: datetime validation in laravel 
Php :: what is the hashmap like in php 
Php :: ent_quotes in php 
Php :: php get max key in associative array 
Php :: php timezone 
Php :: ajax post json data handle in php 
Php :: installing php on ubuntu 
Php :: laravel checkbox checked 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =