2010-11-05 50 views
0

我只是刚刚买了一个网域昨天(cryptum.net),我打算上传一些文件给它。我的问题是我没有一个好的PHP5下载脚本。我只想要一个简单的脚本,将文件保存到用户下载文件夹。这些文件位于网站ftp服务器上。这里是我有这么远什么是简单的PHP文件下载脚本?

<?php 
$conn = ftp_connect("ftp://[email protected]") or die("Could not connect"); 
ftp_login($conn,"username","password"); 

//download script goes here 

ftp_close($conn); 
?> 

回答

1

它使用PHP的强大功能,流另一个非常优雅的解决方案:

<?php 
$ftp_server = 'ftp://username:[email protected]/'; 
$remote_file = 'user/directory/file'; 
$local_file = '/path/to/the/local/file'; 

file_put_contents($local_file, file_get_contents($ftp_server.$destination_file)); 
1
<?php 
//... 
//download script goes here 
ftp_get ($conn, '/destination/on/my/hardDrive', '/file/to/download'); 
//... 
?> 

,你可以使用PHP的卷曲,而不是...