Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,169
    Thanks
    19
    Thanked 65 Times in 64 Posts

    Unzipping files on the server

    Hi, I have a problem, I will soon be recieving some very large csv files that will be zipped - VERY large, they need to be unzipped on the server and processed, ie I will upload them then the processing script will need to unzip, open and put the data into the database and I dont know where to start. I'm not looking for a complete script, as I said, I havent even seen the files yet, I just know that they will be too big to download and open manually (thats all I have been told)
    Just looking for some pointers really.

  • #2
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    http://uk.php.net/zip might be a good place to start, if you have it installed/can install it.
    Otherwise, exec() with 'unzip' could be an option?
    Or, you could write a bash script that unzips the files at a certain time each day (before the PHP script) runs.

  • #3
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,169
    Thanks
    19
    Thanked 65 Times in 64 Posts
    looks like this might do thee trick:
    PHP Code:
    <?

    function unzip($zip_file$src_dir$extract_dir)
    {
     
    copy($src_dir "/" $zip_file$extract_dir "/" $zip_file);
     
    chdir($extract_dir);
     
    shell_exec("unzip $zip_file");
    }

    ?>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •