Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

How To Copy Files Around FTP Using PHP

0

63 views

I am tring to copy a file from one folder to another using the php ftp functions.

e.g

Copy This File: httpdocs/user_images/Services/File 1.jpg

To: httpdocs/user_images/folder11

i have tried to use ftp_fput but i am not have any luck with it.

asked January 31, 2011 10:24 am CST
posted via StackOverflow

3 Answers

1
 

From the manual page on ftp_put on PHP.net:

<?php 
// bool ftp_copy  ( resource $ftp_stream  , string $initialpath, string $newpath, string $imagename ) 
function ftp_copy($conn_distant , $pathftp , $pathftpimg ,$img){ 
        // on recupere l'image puis on la repose dans le nouveau folder 
        if(ftp_get($conn_distant, TEMPFOLDER.$img, $pathftp.'/'.$img ,FTP_BINARY)){ 
                if(ftp_put($conn_distant, $pathftpimg.'/'.$img ,TEMPFOLDER.$img , FTP_BINARY)){ 
                        unlink(TEMPFOLDER.$img) ;                                              
                } else{                                
                        return false; 
                } 

        }else{ 
                return false ; 
        } 
        return true ; 
} 
?>

answered January 31, 2011 11:23 am CST
0
 

Unless you're actually moving files between servers or to somewhere that PHP doesn't have access, use copy()(php)

<?
copy('httpdocs/user_images/Services/File 1.jpg', 'httpdocs/user_images/folder11/File 1.jpg');
?>

answered January 31, 2011 11:23 am CST
0
 
answered January 31, 2011 11:23 am CST

Your answer

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions
Mysql copy into log
January 24, 2011
Hadoop copy directory
January 17, 2011
Mysql databases copy
January 29, 2011
Copy text from a webpage
December 27, 2010