Results 1 to 10 of 10

Thread: Where do I securely store user uploaded files?

  1. #1
    Join Date
    Apr 2009

    Where do I securely store user uploaded files?

    I have an application where registered users will upload various files (.doc, .pdf) and I need them stored somewhere secure so somebody who isn't registered can't access them. Normally I've just had all file uploads to go a folder in the site root, but I'm thinking that probably isn't a good idea.

    Any suggestions on how to make this more secure?

  2. #2
    Join Date
    May 2012
    yeah , well you can store the files on other server like

    for example you have made the app on the domain www.example.com make another subdomain upload.example.com from where all the file validation , uploading and renaming will be done then transfer the file to another subdomain(storage server) like this any name which does not seem that it is saving the files users upload , probably upstor.example.com or any random number and remember to delete the original file from upload.example.com .... hope this is a nice idea and helps too ...

  3. #3
    Join Date
    Apr 2009
    I don't think using another domain is going to be an option with this.

    What about using a .htaccess file and putting that in the main folder where the files are stored? Would that work?

    Or what about placing the folder outside of the root folder of the site? Would that prevent outsiders from grabbing the files but still allow the registered users to access them?

  4. #4
    Join Date
    May 2012
    Well initially I also thought of doing so but I felt that if a intrusor gets access to your main server (www.example.com) then he can easily access the .htaccess file and make the complete folder web accessible but he cant if you place the files on a separate server , that would take the files security one step further.
    Thats why I advised to use a separate server.

  5. #5
    Join Date
    Apr 2009
    So if we went the route of storing them on a separate server, do we get another domain name that points to that server? And how do you move the uploaded files to another server?

  6. #6
    Join Date
    Dec 2012
    I would ignore the suggestion about using a completely different server for security reasons; if someone can hack one of your servers, they can hack the other one too, and you would have bigger problems than them stealing your files if that happened...

    I would probably store the files outside of the web root, so that they're not even accessible directly over the web; then have a script that when accessed, validates that the person is logged in, and then transfers the file to them.

    So your server side script (ie php/dotnet)

    1. checks they're a valid user (ie by the standard user-is-logged-in check that you're doing else where on the site - checking the session or whatever)
    2. sets the correct headers for the file type, eg Content-Type: application/octet-stream
    3. reads the file from wherever it is on the server
    4. outputs it to the user's browser

    1b. if they're not a valid user, the connection is ended and they don't get the secure file.

    this means that they only get the file if they're a valid, logged in user.

  7. #7
    Join Date
    May 2012

    But if they can hack into your validation system which validates the user is logged in or not will get an easily access to the files.
    but if we store the files on different server we can password protect directories which can only be bypassed by the app and we only check which user has logged in and select the particular file or files which he has uploaded .
    Please do Correct me if I am wrong any where.

  8. #8
    Join Date
    Jan 2009
    I would say if a user breaks into another users account by guessing the authentication details then their files would be compromised either way. There is not really a need to store the files on another server, just outside of the web root so users can't upload a file and then access it directly (especially if you are allowing all types of uploads) as a user could directly infect your server by uploading an executable script and then running it by pointing their browser to it.

  9. #9
    Join Date
    May 2012

    Thanks to you too , now can you please tell me how to save the user files outside web root using php , waiting for your response.


  10. #10
    Join Date
    Jan 2009
    Either you store the files above the htdocs (or whatever your base folder is) or you can store them in a sub folder and block all access with htaccess. Then as described above you check authentication (or whatever you are validating) and then output the appropriate headers for the content type, read the file, then echo the contents.

    Probably could search for a couple of different things for this, "htaccess deny access", "upload file to directory php", & "force download dialog php".

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.11103 seconds
  • Memory Usage 2,935KB
  • Queries Executed 15 (?)
More Information
Template Usage (32):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (10)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (72):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates