|
|
|
| Title : |
This is a simple PHP function to copy a remote file into a local drive. So it's a kind of downloader script. Please check if your server allow remote url_fopen, otherwise it won't work. |
| Categories : |
PHP, Filesystem |
 Yeni Setiawan |
| Date : |
Jul 27th 2007 |
| Grade : |
3 of 5 (graded 7 times) |
| Viewed : |
34548 |
| File : |
No file for this code example. |
| Images : |
No Images for this code example. |
|
| Search : |
More code by Yeni Setiawan |
|
| Action : |
Grade This Code Example
|
|
| Tools : |
My Examples List |
|
|
|
|
|
|
|
|
|
|
Like this code?
Show the author your appreciation.
|
| |
| <?php
function copyFile($url,$dirname){
@$file = fopen ($url, "rb");
if (!$file) {
echo"<font color=red>Failed to copy $url!</font><br>";
return false;
}else {
$filename = basename($url);
$fc = fopen($dirname."$filename", "wb");
while (!feof ($file)) {
$line = fread ($file, 1028);
fwrite($fc,$line);
}
fclose($fc);
echo "<font color=blue>File $url saved to PC!</font><br>";
return true;
}
}
?> | |
Usage Example:
| <?php
copyFile("http://test-server.com/file/movie.mpg","myfolder/");
?> | |
|
|
| Differences between two files Categories : PHP, Filesystem, Tip | | | Directory Viewer, Directory Content Viewer, Directory Structure to HTML.
This code will basically create a complete set of HTMLs to let a user
navigate through any directory you want. Excellent code for large file
sharing pages. Categories : Directories, Filesystem, PHP | | | PHP Transfer data from text file to Mysql Table Categories : PHP, PHP Classes, Filesystem, Databases, MySQL | | | Using php3 to upload files, uploading files, file uploads. Categories : PHP, Filesystem, HTTP | | | Random Image Display Categories : PHP, Filesystem, Graphics, HTML and PHP | | | PHP based Contact email form with multiple recipients, text file based, supports departments. Categories : PHP, Email, Beginner Guides, Filesystem | | | Checking to see if a file exists with PHP Categories : PHP, Filesystem, Perl | | | File Explorer, browse, upload, download and edit your web site files with only a browser and a HTTP connection. Categories : Complete Programs, Content Management, Filesystem, PHP | | | How to let a user download a picture by clicking on it instead of needing to right click and Save-As. Categories : HTTP, PHP, HTML and PHP, Filesystem | | | Filling an array with files from any given directory. This example is for the current PHP script's directory. Categories : PHP, Arrays, Filesystem | | | Contents Page - a script to build contents pages. Categories : Complete Programs, PHP, Utilities, Filesystem | | | How to ifconfig down/up a list of IP's Categories : Arrays, Strings, Filesystem, PHP | | | Variable serialization and unserialization. Loading and saving variable structures
to and from file. Categories : Arrays, Filesystem, Variables, Strings, PHP | | | Simple pipe delimited file export program that downloads to a local machine Categories : PHP, Filesystem, Databases, MySQL, HTTP | | | Fetching product details from the commission junction website using php Categories : PHP, FTP, Filesystem, Compression | |
| |
| | | | | Gerard van Beek wrote :1695
Wouldn`t it be simpler to use the copy command?
| |
|
|