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

dplyr + ggplot2: Plotting not working via piping

r ggplot2 dplyr

I want to plot a subset of my dataframe. I am working with dplyr and ggplot2. My code only works with version 1, not version 2 via piping. What's the difference?

Algorithm to quickly find animals away from the herd

algorithm geometry machine-learning spatial-index outliers

I am developing a simulation program. There are herds of animals (wildebeests), and in that herd, I need to be able to find one animal that is away from the herd.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.