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

  • SEARCH
  • Home
  • 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 1065033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T19:45:02+00:00 2026-05-16T19:45:02+00:00

I am currently working on this project which requires me to make a function

  • 0

I am currently working on this project which requires me to make a function which dinamically decides the directory name and then creates a simple .txt file in that directory.

my code is as follows:
($destinatario is a string)

     $diretorio="../messages/".$destinatario;
if (is_dir($diretorio)) {
    ;
}else{
    mkdir($diretorio);
}
$path=$diretorio."/".$data.",".$assunto.",".$remetente.".txt";
$handle=fopen($path,'w+');

fwrite($handle, $corpo);

fclose($handle);

nevermind the portuguese, but the bottom line is that it should create a .txt file using the naming guidelines i’ve provided. The funny thing is that when i do this, php creates this weird file whose filename is “01.09.2010 04”
(with no extension at all) which amounts to the first few characters of the actual filename i’d like to create…

edit($data is actually the output from a call to date(“d.m.Y H:i”))

  • 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-16T19:45:03+00:00Added an answer on May 16, 2026 at 7:45 pm

    Per comment by OP:

    [$data is] actually the output of a call to date(“d.m.Y H:i”)

    The problem is the : character. (Still, there may be other illegal characters in the other parts composing the final file name.)


    EDIT
    The essence of the problem and solution is in the comments to @tchen’s answer. Keep in mind that colon is a valid file name character on (some? all?) *nix platforms but is invalid on Windows.

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

Sidebar

Related Questions

I am working on a project which requires me to download and use this
I'm working on a project that requires that the vertical borders, which are currently
I am currently working on a project which requires migration of content from different
I am currently working on one of my college project which requires the implementation
I currently have this working but it requires me to have a static method
I am currently working on a REST service. This service has an entity which
I'm currently working on a project where we have a large data warehouse which
I am currently working on a project that requires to solve the following problem:
I'm currently working on a big JavaScript project for which we want to define
This project I'm working on requires me to keep a local db of admin

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.