English 中文(简体)
1. 重述所有档案
原标题:Rename all files in folder
  • 时间:2011-11-02 22:56:12
  •  标签:
  • php
  • usort

我的Piper删除了我数据库中选取的图像,删除了希望的形象,需要重新命名左侧的所有其他图像。 因此,我有3个图像:成像1、成像2、成像3等。 Say i 删除成像1, i 先到,unlink(>>,现在需要重新命名为og2 至 img1 ,然后改为og3。

这里是我现在的右铭。

<?php
$dbc = mysql_connect( hostname ,  login ,  password );
if(!$dbc){
die( not connected :   . mysql_error());
}

$db_selected = mysql_select_db("database", $dbc);
if(!$db_selected){
die("could not connect to DB : " . mysql_error());  
}

$username = $_GET[ username ];
$image = $_GET[ imagename ];

$check = mysql_query("SELECT image FROM members WHERE username= $username ");
$findMem = mysql_num_rows($check);

if($findMem > 0){

while($row = mysql_fetch_array($check) or die(mysql_error())){
$images = $row["image"];
$images = $images - 1;
unlink("./$image");

mysql_query("UPDATE members SET image= $images 
WHERE username= $username ");
}

$path = "$username/default/";


$files = glob("{$path}/{*.jpg,*.jpeg,*.png}", GLOB_BRACE);


function filetime_callback($a, $b)
{
  if (filemtime($a) === filemtime($b)) return 0;
  return filemtime($a) > filemtime($b) ? -1 : 1; 
} 

// Then sort with usort()
usort($files, "filetime_callback");

}

?>

如你所看到,我的职能是,在设定日期之前命令所有档案。

我仍然希望设定的日期保持不变,即只需要把档案放在文件夹中。 可能有50个图像,因此它必须成为某种 lo。

Thanks for the help :)

最佳回答
问题回答

暂无回答




相关问题
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 ...

热门标签