English 中文(简体)
当处理上传提交时, 如何创建月 - > 日上传路径目录
原标题:how to create month->day upload path directories when processing upload submit

what is the simple way to create folders and sub-folders as upload path? based on witch day it is example:

-files
 -2012 //year
   -01 //month
     +01 //day
     +02
     +03
     .
     .
     .
     +29
     +30
   +02 //month
   +03
   +04
   +05
   +06
   +07
 +2013
 .
 .
 .

是否有要创建目录的级别或函数?

最佳回答

您可以使用 mkdir () 。 它有一个选项可以递增创建文件夹 。

然后使用您想要的日期构建一条路径, 并确保在函数中添加 < code> true

意思是像:

mkdir("/2012/5/25", 0755, true);

要构建日期路径, 您需要使用 PHP 方法 < code> date () () < code > ) 进行进一步阅读, 并阅读 < a href=" http://php. net/ manual/ en/ opident. date. php" rel = "nofollow" > 文件 < /a > 。

问题回答
$base_dir =  /path/to/your/dir ;
$new_dir = $base_dir.date( /Y/m/d/ );
if(!file_exists($new_dir) AND is_writable($base_dir)) {
    mkdir($new_dir, 0755, true)
}




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签