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 3674630
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:52:41+00:00 2026-05-19T02:52:41+00:00

I know this may be a silly question but i cant seem to find

  • 0

I know this may be a silly question but i cant seem to find just a simple answer.

I have a php script that makes a directory for me when the user starts a new entry.
That directory holds photos for their gallery.

What i would like to do is also create One index.html file inside that new directory with a few lines of html code in it.

How do i do this?

Im guessing that the file would be made like so:

mkdir('users/'.$id.'/index.html',0755);

But how do i add the html into that index.html file?

Or do i have one file on the server and copy it over into there during the MKDIR process?

Anyways a really simple answer would be best as i am very slow in this learning thing.

Thank you
John

New edits…..

<?php

$id = 812; 
mkdir('users/'.$id,0755); 
chmod('users/'.$id,0777);

$fh = fopen( "users/".$id, "w+" ) or die( "Couldn't open file" );
fwrite( $fh, "<html><head /><body><h1>It Works!</h1></html>" );
fclose( $fh );

?>  

Its giving me this error?

Warning: fopen(users/812) [function.fopen]: failed to open stream: Permission denied in stackoverflowtest1.php on line 9
Couldn’t open file

Any ideas? I am on a wamp windows 7 server and not using ftp to edit files but just the www wamp explorer foler.

  • 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-19T02:52:41+00:00Added an answer on May 19, 2026 at 2:52 am

    I’m not sure which language you are using so you’ll either need to update your question or forgive the lack of concrete code. mkdir is for generating directories and not flat files. To do that you’ll need to open then the file handle then print the HTML lines to that handle and then close it.

    A file handle is a pointer to a file. It allows you to manipulate the data in that file ( i.e. read or write it ).

    example code:

    $fh = fopen( "path/to/file/index.html", "w+" ) or die( "Couldn't open file" );
    fwrite( $fh, "<html><head /><body><h1>It Works!</h1></html>" );
    fclose( $fh );
    

    The path to the file needs a file name as a target, sorry that wasn’t clear.

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

Sidebar

Related Questions

Now this may seem like a silly question, but I need to know how
I know this may seem like a math question but i just saw this
I know this may be a silly question. but stil i have a confusion.
I know this may be a silly question for experienced coders. But I have
This may seem like a silly question, but I'd like to know the best
This may be a silly question but... Say you have a sentence like: The
This may be a silly question, but does anyone know of a proof that
I know this may be a silly question but for this application I cannot
I'm not a ruby expert and may be this will seem a silly question...but
Hi guys this question may look to be very silly. But still i have

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.