DEV Community

Cover image for How to download a file from a remote site using PHP cURL
pikasho
pikasho

Posted on

How to download a file from a remote site using PHP cURL

First of all you need to download html dom parser file from sourceforge. Then this code will work for you best.
Here is the code you can download momix.apk file from momix apk site.

PHP Code:

`<?php

$curl = ?https://momixapk.com?;

$cs = REMOTE_FILE "momix.apk" ;

$flag = curl_init();

$flag1 = fopen($cs, "w") ;

curl_setopt_array($flag,

array(

CURLOPT_URL => $curl,

CURLOPT_FILE => $flag1,

)

) ;

$no = curl_exec($flag) ;

curl_close($flag) ;

fclose($flag1) ; `

Discussion (0)