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 Pakainfo.com – 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!.

  How to Create a Wordpress Plugin in 10 Minutes Flat

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 = "http://www.Pakainfo.com/live.jpg";
$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!

  Laravel Multiple middleware from controller in constructor

<?php
//My Personal blog.Pakainfo.com
//author: Jaydeep Gondaliya

if($_POST){
//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";
}else{
echo "Please upload only Any Images Format image/document or Must be files";
}
}
?>

<html>
<head><title>Live24u - Simple File Upload from URL Script!</title></head>
<body>
<h3>Pakainfo.com - 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" />
	</form>
</body>
</html>

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

  How to display cross domain json data using Jquery

Example

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(Pakainfo.com) readers.Your Valuable Feed Back,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.

Leave a Reply

avatar
  Subscribe  
Notify of