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.


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

PHP Code

    $data = file_get_contents($url);
    $new = 'blogMainImage.png';
    file_put_contents($new, $data);
    echo "<img src='blogMainImage.png'>";

Leave a Reply

Your email address will not be published. Required fields are marked *