Secure File Storage

Discussion in 'PHP' started by stephan2307, Apr 12, 2010.

  1. #1
    Hi,

    I am developing an application in which the user will be able to upload certain document.

    What is the best way to store these document to ensure that they are safe? I don't want anyone to be able to access them except the person that uploaded them.

    I came up with the following ideas.

    1. Store them in MySQL and then when needed create document on the fly
    2. Create a folder for each user and store images in there. then password protect folder via .htaccess when files are needed user is automatically logged in to retrieve them. In addition mod_rewrite is used to hide the userid (which would be the folder name )

    Which one is best? Any other way to do it better?
     
    stephan2307, Apr 12, 2010 IP
  2. atlantaazfinest

    atlantaazfinest Peon

    Messages:
    389
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Ehhhh Number 1 i definitely wouldn't do,

    Number 2 is suitable with a few tweaks. Also you can look at using php's encryption functions ex. rsa . blowfish all of that to take it a step further
     
    atlantaazfinest, Apr 12, 2010 IP
  3. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #3
    How would I use the encryption functions to encrypt and then decrypt files?
     
    stephan2307, Apr 12, 2010 IP
  4. atlantaazfinest

    atlantaazfinest Peon

    Messages:
    389
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    atlantaazfinest, Apr 12, 2010 IP
  5. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #5
    How secure would this be?
     
    stephan2307, Apr 12, 2010 IP
  6. atlantaazfinest

    atlantaazfinest Peon

    Messages:
    389
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Depends on which cipher you use.. look into aes 128 (safety margin is larger than aes 256) or blowfish something along those lines... just gotta make sure you implement it correctly
     
    atlantaazfinest, Apr 12, 2010 IP
    stephan2307 likes this.
  7. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #7
    Thanks for your excellent Feedback.

    Is there anyone else that can give advice?
     
    stephan2307, Apr 12, 2010 IP
  8. atlantaazfinest

    atlantaazfinest Peon

    Messages:
    389
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #8
    atlantaazfinest, Apr 12, 2010 IP
  9. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #9
    You can also store files outside of your web directory - in /home/yourname instead of /home/yourname/www and use PHP to content-disposition/attachment and spit it out without letting anyone be able to access it directly over the internet
     
    krsix, Apr 12, 2010 IP