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!.

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

Also Read This πŸ‘‰   How to upload image in codeigniter mysql database and display?

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!

//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

Also Read This πŸ‘‰   Laravel 5.6 Like Dislike rating system with jQuery, Ajax and PHP


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.