Category Archives: Coding

All kinds of Programming.

How to download a file using Curl in PHP – Code Snippet

By | January 13, 2023

Download a File using Curl Here is a quick curl snippet for php, that can download a remote file and save it. <?php set_time_limit(0); // File to save the contents to $fp = fopen ('files2.tar', 'w+'); $url = "http://localhost/files.tar"; // Here is the file we are downloading, replace spaces with %20 $ch = curl_init(str_replace(" ","%20",$url));… Read More »

How to extract tar.gz archives in Php

By | May 1, 2023

In a previous article we learned how to . Now lets do the reverse, that is extract tar.gz archives and get the files out. The code to extract a tar.gz archive is very simple and uses PharData class. Here is an example // decompress from gz $p = new PharData('files.tar.gz'); $p->decompress(); // creates files.tar //… Read More »

How to use proxy with curl in Php

By | May 1, 2023

Proxy with Curl Curl is a very useful library for transferring data over various protocols like http, ftp, https etc. In other words curl can be used to programatically download a web page, or upload file to ftp etc. It also supports using a proxy. This means that curl requests can go through a proxy… Read More »

Convert excel to csv in php

By | March 11, 2013

When working with data import and export for example, file formats like csv and excel are commonly used. Data can be exported to csv format and imported elsewhere. Also data might be entered manually in an excel file and then imported in the database. So there might be a need to convert excel files to… Read More »

Ajax based streaming and progress monitor

By | May 2, 2023

Streaming (Comet) Streaming means to send content part by part at some intervals in the same request. Or in other words, the client is able to process the response part by part, instead of waiting for the whole transfer to complete. In the context of http and web applications it is more specifically called Comet…. Read More »