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

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 :: integer data type php 
Php :: add custom shortcode in contact form 7 
Php :: array_chunk in php 
Php :: how get the size of image in laravel 
Php :: array shift php 
Php :: Movie Name -inurl:(htm|html|php|pls|txt) intitle:index.of “last modified” (mp4|wma|aac|avi) 
Php :: php artisan vendor:publish --provider="MaatwebsiteExcelExcelServiceProvider 
Php :: not equal in laravel blade 
Php :: bind to class blade laravel 
Php :: comment split une chaine de caratere en php 
Php :: Predefined Constants php 
Php :: laravel migration column types 
Php :: database, counts,php, 
Php :: php session array 
Php :: php inline if condition date time 
Php :: php get last day of month 
Php :: api resource create in laravel 
Php :: laravel admin panel free package 
Php :: match php 
Php :: post format wordpress 
Php :: Invalid credentials. symfony 
Php :: change php version on ubuntu 
Php :: php get array key like 
Php :: how to access array using key in php 
Php :: laravel migration int length 
Php :: this app is not allowed to query for scheme fb-messenger" 
Php :: Generating Random String In PHP Using random_bytes() function. (Cryptographically Secure) 
Php :: laravel auth sha-1 
Php :: heap sort php 
Php :: order by pre get posts 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =