tags:

views:

39

answers:

2

Is there a way to add files to a zip file from another server with php's zip extension? ie. addFile(array('localfile.txt,'http://www.domain.com/remotefile.txt')) (that obviously does not work)

I suppose I can download the files to a temporal folder and then add them to the zip file, but I was looking for a more automated solution or a function already made

A: 

Fetch them with cURL, add them from TEMP directory.

vartec
+1  A: 

It's not hard to read remote files in PHP.

file_get_contents("http://example.com/remote.txt");

Or to copy them locally:

copy("http://example.com/remote.txt", "/tmp/local.txt");

Whichever way you do it, the contents are going to have to be transferred to a local temp folder or memory before you can do anything with them.

nickf
as I said, I know how to read remote files and put them in a temp folder. I only was wondering if there was some way to do it with the zip extension or some library (just to not reinvent the wheel). But thanks anyway
Borgtex