Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6675949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:55:31+00:00 2026-05-26T03:55:31+00:00

So I am creating trying to create a PHP script where the client can

  • 0

So I am creating trying to create a PHP script where the client can create a folder with a 10 digit name of random letters and numbers, and than save the document they are currently working on into that folder. Its like a JSfiddle where you can save what you are currently working on and it makes a random folder. My issue is that it wont create my directory, and the idea is correct, and it should work. However, PHP isn’t saving an Error Log so I cannot identify the issue. Here’s what I got so far.

PHP

save_functions.php

<?php
function genRandomString() {
    $length = 10;
    $characters = "0123456789abcdefghijklmnopqrstuvwxyz";
    $string = '';    
    for ($p = 0; $p < $length; $p++) {
        $string .= $characters[mt_rand(0, strlen($characters))];
    }
    return $string;

}
<?php
function createFolder() {
    $folderName = genRandomString(); //Make a random name for the folder
    $goTo = '../$folderName';//Path to folder
    while(is_dir($goTo)==true){ //Check if a folder with that name exists
        $folderName = genRandomString();
        $goTo = '../$folderName';
    }
    mkdir($goTo,7777); //Make a directory with that name at $goTo
    return $goTo; //Return the path to the folder
}
?>   

create_files.php

<?php
include('save_functions.php');//Include those functions
    $doc = $_POST['doc'];//Get contents of the file
    $folder = createFolder();//Make the folder with that random name
    $docName = '$folder/style.css';//Create the css file
    $dh = fopen($docName, 'w+') or die("can't open file");//Open or create the file
    fwrite($dh, $doc);//Overwrite contents of the file
   fclose($dh);//Close handler
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:55:32+00:00Added an answer on May 26, 2026 at 3:55 am

    The call to mkdir($goTo,7777) has wrong mode, this is usually octal and not decimal or hex. 7777 is 017141 in octal and thus tries to set non-existent bits. Try the usual 0777.

    But why don’t you just use tempnam() or tmpfile() in your case?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using php, I'm trying to create a script which will search within a text
I am trying to create a user login/creation script in PHP and would like
I'm creating a CSS editor and am trying to create a regular expression that
I'm trying to create my first data mart. I am creating my dimension table
I'm creating an AJAX form. The problem is when I'm trying to create a
I'm trying to use PHP to create a file, but it isn't working. I
I'm trying to write a simple PHP script which automatically sets up new etherpads
I am creating a simple script say a.php. I know that drupal 6 creates
im trying to create a block that shows a random image from a pool
hi i am trying to create a pdf files in php useing dompdf-0.5.1 i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.