Very Simple PHP Script to Upload Image or file from an URL

Very Simple PHP Script to Upload Image or file from an URL

Very Simple PHP Script to Upload Image or file from an URL

In this Post We Will Explain About is Very Simple PHP Script to Upload Image or file from an URL With Example and Demo.Welcome on – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Basic File Uploading from a URL Using PHP Example

In this post we will show you Best way to implement How can I upload an image from a URL in PHP, hear for Upload an image and store in database using php code with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Read Also:  PHP upload custom file in ckeditor Example

Have you any used PHP function file_get_contents and used to file_put_contents?.

If you are a PHP, jQuery, HTML or Web Developer donโ€™t worry!. Here is the simple PHP Source code will do the Best Tips and trick for you as well as you can very easily step by step Learning by reading the Your any stuck comments in the source code itself!

Display the Script below (please create sure your dir folder is writable or execution change (permission: 775 or 777)) ๐Ÿ™‚

// this Most Imp three lines of scripts will upload Only an image or files from any differnt url to the your dir or folder!
$myurl = "";
$filename = basename($myurl);
file_put_contents("media/$filename", file_get_contents($myurl);

For your File convenience We have Explain a small PHP program with Source code where you can simple copy this script and paste as well as download this script and use it in your web-application or own PHP Any projects!

Read Also:  How to upload image in codeigniter mysql database and display?

//My Personal
//author: Jaydeep Gondaliya

//Sumple fetch the url
$my_live_url = $_POST['url'];

//Simple add time to the Retrive current filename
$myfname = basename($my_live_url);
list($txt, $file_ext) = explode(".", $myfname);
$myfname = $txt.time();
$myfname = $myfname.".".$file_ext;

//check if the Your Images or files are only image / document
if($file_ext == "jpg" or $file_ext == "png" or $file_ext == "gif" or $file_ext == "doc" or $file_ext == "docx" or $file_ext == "pdf"){

$fileupload = file_put_contents("media/$myfname",file_get_contents($my_live_url));
//check Your Status success
if($fileupload)  echo "Success: <a href='media/".$myfname."' target='_blank'>Check File/Images Uploaded</a>"; else "please check your Dir or folder permission";
echo "Please upload only Any Images Format image/document or Must be files";

<head><title>Live24u - Simple File Upload from URL Script!</title></head>
<h3> - Very Simple File Upload from URL Script Example</h3>
Paste Enetr the url and Press the hit enter!
	<form action="" method="post">
		Your Enetr Validate URL: <input type="text" name="url" />

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example

Read Also:  Removing index.php From Codeigniter URL htaccess


I hope you have Got What is Upload Image From URL Using PHP And how it works.I would Like to have Feed Back From My Blog( readers.Your Valuable Feed Back,Any Question,or any Comments about This Article( Are Most Always Welcome.

About Pakainfo

I am Jaydeep Gondaliya, a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Pakainfo →

Leave a Reply

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