Compress and download from 3rd party ftp server using php

I'm downloading files from 3rd party ftp server using php. But file is more then 15mb. So it took more time to download. I have an idea to compress and download on the fly from ftp server. Is it possible to do so?

Thanks in advance.

Answers


You have to download the original file, one way or another. You can zip it with PHP, but only after you download the original file to your server. What you are asking is it the source server can compress it for you, which with FTP is not possible.

Consider using CURL to download the file from the FTP server. It's much more resiliant.

$curl = curl_init();
$file = fopen("file.zip", 'w'); ##where you want to save it
curl_setopt($curl, CURLOPT_URL, "ftp://ftp.sunet.se/file.zip"); #input
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FILE, $file); #output
curl_setopt($curl, CURLOPT_USERPWD, "$_FTP[username]:$_FTP[password]");
curl_exec($curl);
curl_close($curl);
fclose($file);

Source


Need Your Help

How to parse a string for newline characters and backslash in iPhone app?

iphone objective-c cocoa-touch ios4 ascii-art

I am making an app where there is a requirement to store ASCII art into database.

Upload file in OpenRasta using PUT

.net rest file-upload openrasta

Is it possible to upload a file in OpenRasta using the PUT post method?

Deleting duplicates in an array (C++)

c++ arrays duplicates

I saw an older post on here asking how to do relatively the same thing, but their approach was different and i'm interested to know the hole in my program.