Download a file from web to local

Use this function to download a file from web to local machine.

function WgetFile( $URL, $dir )
{
   $nomefile = $dir . "/" . basename( $URL );
   if ( copy( $URL, $nomefile ) ) {
      return true;
   }
   else {
      return false;
   }
}
 
//Save file to drive c:
WgetFile( 'http://vtwo.ir/src/v2-logo.png', 'c:/' );

Tags

No tag here.

Recommended pages

Delete or Remove all files and folders in a directory‎...

If you want to delete everything from folder (including subfolders) use this function. function removeDir( $dir ) { if ( is_dir( $dir ) ) { $objects = scandir( $dir ); foreach ( $o...

Human readable file size...

This function return formatting of file sizes in a human readable format. function formatFileSize( $size ) { $file_size = $size; $i = 0;   $name = array( 'byte', 'kB', 'MB', '...

File size calculator...

File size calculator function return file size format into kb, mb or gb. function file_size($size, $out = 'kb', $precision = 2) { switch ($out) { case 'kb': return round($...

alphaID - Translates a number to a short alhanumeric version...

Translates a number to a short alhanumeric version. e.g.: 9007199254740989 --> PpQXn7COf In most cases this is better than totally random ID generators because this can easily avoid duplicate ID's. Fo...