rich remer
rich remer

Reputation: 3577

PHP mixing zip and ftp stream wrappers

I can't figure out how to combine the zip:// and ftp:// stream wrappers. I want to open read a stream to a file within a zip archive on a remote FTP server.

The following two work as expected; I can either open an FTP stream to the server or I can open a stream to a file within a zip archive.

fopen("ftp://user:pass@host/home/user/file.zip", "r");
fopen("zip://file.zip#file.txt", "r");

I'd like to combine the two and do something like.

fopen("zip://ftp://user:pass@host/home/user/file.zip#file.txt", "r");

But with that approach I get: failed to open stream: operation failed

Not sure how to find out what's causing the error, so I don't know if this is even possible.

Upvotes: 2

Views: 1031

Answers (1)

emersion
emersion

Reputation: 443

It seems that:

<?php
copy('compress.zlib://ftp://username:[email protected]:21/path/to/file.dat.gz', '/local/copy/of/file.dat');

works.

See http://ciaranmcnulty.com/simplifying-file-operations-using-php-stream-wrappers

Upvotes: 1

Related Questions