Menu Close

Upload Image From URL in PHP


Let’s see  how to upload image from the URL in PHP.

It is very simple to upload image from URL to server.

Here, you have to enter the complete URL including image name and clicking on upload button then image will upload to server.

Upload Image From URL using PHP.

Create a HTML form to submit an image URL

<!DOCTYPE html>
        <form method="POST">
            <input type="text" name="image_url" placeholder="Enter image url">
            <input type="submit" name="upload_image" value="Upload">

PHP snippet to upload an image to server on the form submission.

if(isset($_POST['upload_image'])) {
    $src_image =   file_get_contents(filter_input(INPUT_POST, "image_url"));
    $new_info = "images/new.jpg";
    $status = file_put_contents($new_info, $src_image);
        echo '<img src="images/new.jpg">';   
    } else {
        echo "not uploaded";    

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?


Posted in PHP

Leave a Reply

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

You can also read...