Closed Thread Icon

Topic awaiting preservation: PHP copy 'directory' from FTP to FTP (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=12861" title="Pages that link to Topic awaiting preservation: PHP copy &amp;#039;directory&amp;#039; from FTP to FTP (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: PHP copy &#039;directory&#039; from FTP to FTP <span class="small">(Page 1 of 1)</span>\

 
Synthetic
Paranoid (IV) Inmate

From: under your rug,
Insane since: Jul 2001

posted posted 08-14-2003 08:02

I've seen many scripts to upload individual files to a ftp via a web interface, thats not what i need...

Basicly I've got a directory I end up uploading over and over to different hosts, and have to chmod it over each time. So I was thinking since I've got a directory of folders and files on a ftp, they are already chmodded the way i want them why not figure out how to copy the directory to new server with php.

Now i'm looking for a script to copy those the directory exactly as i have it to any server of my choosing. The scipt would have a config part where i told it what files to tranfer, and to keep whatever chmod values they already had.

So basicly i'd store the script on my server, and the script would have values to input each time i'm transfering to a server,

so if installing to ftp.msn.com/uploads/dir/ with username/password

Host - ftp.msn.com
Username - username
Password - password
path - /uploads/dir/

I think i can manage to find the revelant php functions for this, but thought i'd check if something like this might exist already first

If not guess i've got a long task of reading the manual ahead

[This message has been edited by Synthetic (edited 08-14-2003).]

Synthetic
Paranoid (IV) Inmate

From: under your rug,
Insane since: Jul 2001

posted posted 08-22-2003 05:51

Peakabo!

(ok one bump to see if anyone has something, then i'll leave it be)

Synthetic's Chess Player Page

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 08-22-2003 09:16

well, I know a friend of mine is doing this... it's not to complicated. most of his code is actually processing what files the user selected, not doing the right ftp_commands. and the manual is pretty straightforward on it as well.

so holler, if you go ahead and need specific help.

don't have a prefab script for you though.

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 08-22-2003 16:04

Synthetic: Can you not do it in something like SmartFTP?

You can open 2 different connections to different sites and I suspect you can just drag and drop the folder between the 2 sites.

Not a cunning scripting solution but............

___________________
Emps

FAQs: Emperor

Synthetic
Paranoid (IV) Inmate

From: under your rug,
Insane since: Jul 2001

posted posted 08-24-2003 06:29

Yes i've been doing that currently, basicly I've got some debugging packages that have to be uploaded over and over to many different servers that we troubleshoot.

And having a ftp upload script where we could just type in where it's going and the user/pass to that server would make life much easier. Also I end up traveling a lot for work and not every work station I'm at is going to have smartFTP. Most run Win 2k and due to access rights, I often am not able to install programs on them either so a web based interface is quite usefull when trying to ftp something server to server for a client.

I've looked around and it doesn't seem anyone has really made public this type of script, if one has ever been made at all. So I'll probably start on it next week on my own. I'll be sure to post back if I need any specific help as TP suggested

Anyway thanks for the interest, will probably be back later, take care

[This message has been edited by Synthetic (edited 08-24-2003).]

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 08-24-2003 09:05

On the following web site you'll find a function that recursively uploads files via FTP and that's basically everything that you need :-)
http://rufy.com/tech/archives/000026.html

Here's a basic script:

$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

if ((!$conn_id) &#124;&#124; (!$login_result))
{
&nbsp;&nbsp;&nbsp;&nbsp;print("FTP connection has failed!");
&nbsp;&nbsp;&nbsp;&nbsp;exit;
}

// This function comes from before mentioned web site
ftp_putAll($conn_id, $src_dir, $dst_dir);

ftp_close($conn_id);

BTW You can tweak ftp_putAll() function to also properly chmod files and choose appropriate transfer type (binary / ascii) depending on file type. Oh and one more thing, you should protect the script so that you are the only one who can access it...


Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 08-24-2003 15:02

and always remember: there's only one appropriate way to transfer files: Binary ;-)

Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 08-24-2003 16:53

As winessed by TP's FTP server, which if you aren't running in binary says 'ASCII tastes bad, dude'

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 08-26-2003 08:28

Although ASCII transfers consume a lot of CPU time and even more bandwidth than transferring files in binary mode, ASCII transfers are only way to properly upload text files which are left in Windows format (CR/LF line endings), or you'll end up with files that have famous "^M" character at the end of each line, which they will seriously broke PERL scripts, for example. Of course, the proper way would be to convert files to Unix format (LF line endings) before uploading, but not many people do that...


Synthetic
Paranoid (IV) Inmate

From: under your rug,
Insane since: Jul 2001

posted posted 08-28-2003 15:07

Got busy with stuff and forgot to check back, anyway appreciate the input

Oh and thanks for the script maX that will be a good start.

Synthetic's Chess Player Page

« BackwardsOnwards »

Show Forum Drop Down Menu