Skip to content

Instantly share code, notes, and snippets.

@muhfaris
Last active November 30, 2017 22:53
Show Gist options
  • Save muhfaris/703c9d429a4879dd320e7636ab29e86f to your computer and use it in GitHub Desktop.
Save muhfaris/703c9d429a4879dd320e7636ab29e86f to your computer and use it in GitHub Desktop.
download file from php to server
<?php
$url = 'https://wordpress.org/latest.zip' ; //url file
$parse_url = parse_url($url) ;
$path_info = pathinfo($parse_url['path']) ;
$file_extension = $path_info['extension'] ;
$save_path = 'files/' ; //destination /name/folder/here
$file_name = 'name' . "." . $file_extension ;
file_put_contents($save_path . $file_name , fopen($url, 'r'));
# Create folder files
# set permission to 777
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment