Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

How to Upload Image From URL Using PHP

by
Category:php
php
How to Upload Image From URL Using PHP

In this tutorial, i will tell you how to upload image from URL in PHP. You have to enter complete path of image in text box and then click submit to upload image. I write here basic simple script to upload an image file from URL. You may also like Multiple file upload in Codeigniter and Multiple Image Upload in PHP.

HTML Code

<html>
    <body>
        <form method="post" action="">
            <input type="text" name="img_url" placeholder="Enter Image URL">
            <input type="submit" name="get_image" value="Submit">
        </form>
    </body>
</html>

PHP Code

<?php
if(isset($_POST['get_image']))
{
    $url=$_POST['img_url'];
    $data = file_get_contents($url);
    $new = 'blogMainImage.png';
    file_put_contents($new, $data);
    echo "<img src='blogMainImage.png'>";
}
?>

0 Comments


Html code work in comment box


Related Post