How to create password protected zip files using PHP?

Discussion in 'PHP' started by rasana, Aug 12, 2008.

  1. #1
    Hi All,

    How to convert files(i.e. txt, video files, .doc ect) into password protected .zip format on wamp/xamp server?
     
    rasana, Aug 12, 2008 IP
  2. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    A quick google says it can't be done, consider using command line tools through exec()?
     
    matthewrobertbell, Aug 13, 2008 IP
  3. gameOn

    gameOn Member

    Messages:
    624
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    35
    #3
    i dont get it.. U cn easily pass protect an archieve during compression (with rar,zip etc) itself and then load it to a server ..
     
    gameOn, Aug 13, 2008 IP
  4. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I think he wants to generate zip files on the fly.
     
    matthewrobertbell, Aug 13, 2008 IP
  5. CarcaBot

    CarcaBot Active Member

    Messages:
    389
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #5
    simple
    
    echo system('zip -P pass file.zip file.txt');
    
    Code (markup):
    /CarcaBot
     
    CarcaBot, Aug 13, 2008 IP
  6. rasana

    rasana Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Let me explain requirement

    I'm working on a project where users download tutorials.
    tutorials are stored in a directory.
    when user clicks on download that particular tutorial file should get convert into ZIP format and password should assigned to zip file.
    how would I do that using PHP on wamp or xamp?
     
    rasana, Aug 13, 2008 IP
  7. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #7
    look at winzip command line documentation
     
    matthewrobertbell, Aug 16, 2008 IP
  8. priyahdarsini

    priyahdarsini Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    echo system('zip -P pass file.zip file.txt');

    The above is not working. No errors are displayed simply shows a blank screen and zip file is not created. Pls let me know if I need to add some other library
     
    priyahdarsini, Jan 17, 2009 IP
  9. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #9
    There are some classes that will let you do it on phpclasses.org

    Peace,
     
    Barti1987, Jan 17, 2009 IP
  10. priyahdarsini

    priyahdarsini Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    I searched in phpclasses.org . I am able to find classes for creating zip files without password protection. Pls let me know the class with password protection
     
    priyahdarsini, Jan 18, 2009 IP
  11. shavin

    shavin Peon

    Messages:
    132
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    i have a similar request.
    i saw a site where they allow you to add password to zip files.
    it means it should be possilbe.
     
    shavin, Jun 5, 2009 IP
  12. shavin

    shavin Peon

    Messages:
    132
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    i have a similar request.
    i saw a site where they allow you to add password to zip files.
    it means it should be possible.
     
    shavin, Jun 5, 2009 IP
  13. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #13
    Why do it so difficult? Just make the .zip-file, and have the user enter a password to get access to download the file instead.
     
    PoPSiCLe, Jun 5, 2009 IP