Jump to content

Search the Community

Showing results for tags 'mkdir'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 4 results

  1. I am unsuccessfully able to do the following: User creates an account After login, checks server if user has their own folder created If doesn't exist, create it Copy files from source_code to this new folder My code does create a folder, but no files appear inside it. Been trying to find an example with google search for the past 3 days with no luck. I am running LAMP on Linux Mint OS to run my PHP webpages. Can anyone tell me if issues with this section of coding? <?php function wait_time($seconds) { $seconds = abs($seconds); if ($seconds < 1): usleep($seconds*1000000); else: sleep($seconds); endif; } $file1 = "blank.html"; $file2 = "channel_video.php"; $file3 = "clear_playlist.php"; $file4 = "confirm.html"; $file5 = "index.html"; set_time_limit(0); //prevent script from timing out $account = $_POST["account_name"]; $src = "source_code/"; $dst = $account."/"; echo 'Setting up your account page ->.'; mkdir($account, 0777, true); echo '.'; //create folder with full write permissions wait_time(2000); //wait 2 seconds before copying files over copy($src.$file1, $dst.$file1); echo '.'; wait_time(2000); //wait 2 seconds before copying files over copy($src.$file2, $dst.$file2); echo '.'; wait_time(2000); //wait 2 seconds before copying files over copy($src.$file3, $dst.$file3); echo '.'; wait_time(2000); //wait 2 seconds before copying files over copy($src.$file4, $dst.$file4); echo '.'; wait_time(2000); //wait 2 seconds before copying files over copy($src.$file5, $dst.$file5); echo '.<- setup finished<br>'; ?> Thanks for any input you can provide.
  2. I need help im building a website that is around social networking. each user has their own profile page. I have my registering code done. But now i want to add into it where when a user registers it adds a folder for them by their username. for example on my database side I have a folder called user. So when EX: Johnny registers then under that folder user he will have a folder for him called Johnny. Inside of johnnys folder is where I want to store his Pics ETC. The code I currently have is this just dont know how to make this mkdir happen. Please any response will help. <?php $submit = $_POST['submit']; // form data $fullname = strip_tags($_POST['fullname']); $username = strip_tags($_POST['username']); $password = strip_tags($_POST['password']); $confirmpassword = strip_tags($_POST['confirmpassword']); $date = date("Y-m-d"); if($submit) { //connect to database $connect = mysql_connect("XXXX", "XXXX", "XXXX"); mysql_select_db("XXXX"); $namecheck = mysql_query("SELECT username FROM user WHERE username='$username'"); $count = mysql_num_rows($namecheck); if ($count!=0) { die("Username is already taken!"); } // check for existance if($fullname&&$username&&$password&&$confirmpassword) { if($password==$confirmpassword) { if (strlen($username)>25||strlen($fullname)>25) { echo "Length of username or full name is too long!"; } else { if (strlen($password)>25||strlen($password)<6) { echo "Your password must be between 6 and 25 characters!"; } else { //register the user // encrypt password $password = md5($password); $confirmpassword = md5($confirmpassword); $queryreg = mysql_query(" INSERT INTO user VALUES('','$fullname','$username','$password','$date') "); die("You've successfully registered! <a href='index.php'>Click here to return to the login page!</a>"); } } } else echo "Your password does not match!"; } else echo "Please enter all fields!"; } ?> <html> <head> <meta charset="UTF-8"> <title>My Web Page</title> <link rel="stylesheet" href="style/style.css"> </head> <?php include_once("templates/template_pageTop.php"); ?> <body> <div id="pageMiddle"> <?php echo "<h1>Sign Up</h1>"; ?> <p> <form action='register.php' method='POST'> <table> <tr> <td> Full Name: </td> <td> <input type='text' name='fullname' value='<?php echo $fullname ?>'> </td> </tr> <tr> <td> Username: </td> <td> <input type='text' name='username' value='<?php echo $username ?>'> </td> </tr> <tr> <td> Password: </td> <td> <input type='password' name='password'> </td> </tr> <tr> <td> Confirm Password: </td> <td> <input type='password' name='confirmpassword'> </td> </tr> </table> <p> <input type='submit' name='submit' value='Create Account'> </form> </div> <?php include_once("templates/template_pageBottom.php"); ?> </body> </html>
  3. This is what I have: mkdir($username); $file=fopen($username."/index.htm","w"); fwrite($file,"<html>"."</html>"); fclose($file); where $username refers to what the user entered for their username. The .php I'm using this code in is merely for a signup process. I'm extremely new to PHP (like, today), so please go easy on me.
  4. Hi, This is a screenshot of the script I'm trying to finish: A simple page, with an upload box, upload button, dropdown menu with directories, text box and a Create button. I can't see what's wrong in the code, as the folder is not getting created. What I'm trying to do is, when the 'Create' button is clicked: Get path from drop down menu Get text from text box Create a new folder in the selected directory (from drop down menu) with the name being the value from the textbox. This is the code: <?php include("login.php"); ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>FileStore - Upload Files</title> <link rel="stylesheet" href="./CSS/style.css" type="text/css" media="screen, projection" /> </head> <body> <div id="wrapper"> <header id="header"> <div id="header-content"> <strong><h1>FileStore</h1></strong> Upload multiple files at once! </div> <div class="login-info" > <?php if ($isLoggedin === false) { echo ' <form action="" method="POST"> Username: <input name="username" > Password: <input type="password" name="password" size="8"> <input type="submit" name="submit" value="Login"> </form>'; echo "<p align='right'>You are not logged in.</p>"; echo "<b><a href='registration.php'>Register</a></b>"; }else{ echo $welcomeMsg; } ?> </div> </header><!-- #header--> <section id="middle" align="center"> <div id="container"> <br><br> <div id="content"> <strong><h1>Upload files</h1></strong><br><br> <div id="upload-file" > <form action="" method="post" enctype="multipart/form-data"> <input type="file" value="" name="upload[]" multiple> <button type="submit">Upload!</button> </form> <form action="" method='post' > <select name="myDirs"> <option value="" selected="selected">Select a folder</option> </form> <?php include("dbConfig.php"); global $userid; global $up_path; global $sPath; $Username = $_SESSION["username"]; $sql = "SELECT UserID FROM users WHERE Username = '".$Username."'"; $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { $userid = $row['UserID']; } $sPath = realpath("./files/" . $userid ); if (!file_exists($sPath)) { mkdir($folder_path, 0777, true); chmod($folder_path, 0777); } if (chdir($sPath)) { $iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($sPath, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST); foreach($iterator as $file) { if($file->isDir()) { echo '<option value="'.$file.'">'.$file."</option>\n"; } } echo var_dump($file); } echo "<form action='' method='post' name='dircreation'>"; echo "<input type='text' name='newDir' > "; echo "<input type='submit' value='Create'>"; echo "</form>"; if(isset($_POST['dircreation'])) { $selected_path = $_POST["myDirs"]; $newDir = $_POST["newDir"]; //$fPath = realpath($sPath. "/" . $file . "/"); $folder_path = $selected_path . "/" . $newDir . "/" ; var_dump($folder_path); if (!file_exists($folder_path)) { mkdir($folder_path, 0777, true); chmod($folder_path, 0777); echo "Folder" . $newDir . "created."; echo "Redirecting to upload page.."; // header( 'Location: upload.php' ) ; } else { echo "Error creating " . $newDir; } } else if (isset($_POST['upload[]'])) { $error_message[0] = "Unknown problem with upload."; $error_message[1] = "Uploaded file too large (load_max_filesize)."; $error_message[2] = "Uploaded file too large (MAX_FILE_SIZE)."; $error_message[3] = "File was only partially uploaded."; $error_message[4] = "Choose a file to upload."; $vpath = strlen($userid); $upload_dir = './files/' . (string)$userid . '/'; $num_files = count($_FILES['upload']['name']); if (!file_exists($upload_dir)) { mkdir($sPath, 0777, true); chmod($sPath, 0777); } else { for ($i=0; $i < $num_files; $i++) { $upload_file = $upload_dir . urlencode(basename($_FILES['upload']['name'][$i])); if (@is_uploaded_file($_FILES['upload']['tmp_name'][$i])) { if (@move_uploaded_file($_FILES['upload']['tmp_name'][$i], $upload_file)) { //Great success... echo basename($upload_file) . " has been uploaded. <br>"; //$content = file_get_contents($upload_file); //echo $content; } else { print $error_message[$_FILES['upload']['error'][$i]]; } } else { print $error_message[$_FILES['upload']['error'][$i]]; } } } } ?> </div> </div><!-- #content--> </div><!-- #container--> <aside id="sideLeft"> <div id="menu-x" align="center"><br> <strong>Menu</strong><br><br> <div class="menu"> <ul> <li><a href="index.php">Home</a></li> <li><a href="upload.php">Upload</a></li> <li><a href="files.php">Files</a></li> <li><a href="about.php">About</a></li> <li><a href="help.php">Help</a></li> <li><a href="#">Logout</a></li> </ul> <br style="clear:left"/> </div> </div> </aside><!-- #sideLeft --> </section><!-- #middle--> <footer id="footer"> <strong>FileStore:</strong> A CMT 3315 Project by Brian Livori </footer><!-- #footer --> </div><!-- #wrapper --> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.