upload file using link in php

How to upload file using link in php

in this tutorial we will show you how to upload file using link in php for this we will be using php at our back-end server that will upload a file to our server you can check the demo and download the sample code from the link below you can also comment your views if you have any doubt i will try my best to provide you support regarding the topic.

DEMO DOWNLOAD CODE




creating a file upload using php is very simple and even you can do that writing few lines of code you can check the code below and upload your file using link by using php as your server and

code to upload file using link in php

[php]function download($url)
{
$status = "file do not exist";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($code == 200)
{
$status = "0";
}
curl_close($ch);
if ($status == "0")
{
$name = "abc.png";
if (file_put_contents("uploads/$name", file_get_contents($url)))
echo "file uploaded";
}
else
{
echo $status;
}
}

$url = "https://devlopersguide.com/wp-content/uploads/team-hands-linked-together_925x.jpg";
echo download($url);[/php]

 

$url is the link to download file here

$code check if the file exist or not it is real link or not

DEMO DOWNLOAD CODE

 

if you liked this article subscribe us for more !! also consider sharing it with Friends who are in need of them you can share them from link below

Leave a Reply

avatar
  Subscribe  
Notify of