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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Sep 2010
    Posts
    331
    Thanks
    9
    Thanked 6 Times in 6 Posts

    How to create folder?

    How would you create a folder for user files when the user registers? It requires the $_FILE(S?) global variable correct?
    Coding is a challenge, get used to it
    Always remember to debug
    Try the guess & check method
    Break it down into simple steps

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Nope. You issue a mkdir.
    Although the worth is questionable. You'd be better off tracking data within the database and using your own directories which could be logically partitioned if you need them to be (filesystems used to have quite a low limitation on the number of files per directory, so we'd split them up based on names and user ids).
    Although if everything is grouped by a single user, it does make deletions easier. So I guess that would be a pro for that.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New Coder
    Join Date
    Jan 2011
    Posts
    75
    Thanks
    1
    Thanked 2 Times in 2 Posts
    This is your solution. What this code is doing is finding if the folder "DESIREDFOLDER" folder exists on your server; if not, it will create one for you; if so, it will not do anything. Also, change "DESIREDFOLDER" do your desired folder name. Have fun.

    PHP Code:
    <?
        $dirname 
    $_POST["DirectoryName"];
        
    $filename = ("/home/site/public_html/DESIREDFOLDER/");
     
        if (
    file_exists($filename)) {
            echo 
    "";
        } else {
            
    mkdir("/home/site/public_html/DESIREDFOLDER/"0777);
            echo 
    "";
        }
    ?>

  • #4
    New Coder
    Join Date
    Apr 2010
    Posts
    55
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by Fou-Lu View Post
    Nope. You issue a mkdir.
    Although the worth is questionable. You'd be better off tracking data within the database and using your own directories which could be logically partitioned if you need them to be
    That is it. Make directories based on a better logic based on the users you have and amount of files you are expecting to store. It will also be a secure solution, otherwise anyone who know the userame could access all the files. Refer all files stored in the database and use random names for stored files.
    Hosting Reviews and Discounts: Bluehost Coupon and Hostmonster Coupon


  •  

    Posting Permissions

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