Jump to content

[SOLVED] adding 1


anf.etienne

Recommended Posts

My guess after re-reading your question would be that you are trying to rename files in a folder to consecutively numbered names. If so:

 

<?php

$count = 1;

foreach(glob('*.jpg') as $filename) {

copy($filename, $count.substr($filename, -4));
$count++;
}

?>

 

That should do it... You could also use unlink() after the copy to remove the original file.

 

Hope that helps

Link to comment
Share on other sites

i have tried it seperately from my main code and it works......but trying to incorporate it into my main code i cant figure out.

 

here is the coding.....can someone point me in the right direction.....thanks again for the help before and for this in advance

 

<?
while(list($key,$value) = each($_FILES['images']['name']))
	{
		if(!empty($value))
		{
			$filename = $value;
				$filename=str_replace(" ","_",$filename);// Add _ inplace of blank space in file name, you can remove this line

				$add = "upload/$random_digit/$filename";
				$tempFLDR = "upload/imgtemp/$filename";
                       //echo $_FILES['images']['type'][$key];
		     // echo "<br>";
				copy($_FILES['images']['tmp_name'][$key], $add);
				chmod("$add",0777);
				copy($_FILES['images']['tmp_name'][$key], $tempFLDR);
				chmod("$tempFLDR",0777);

$count = 1;

foreach(glob('*.jpg') as $filename) {
   
   copy($filename, $count.substr($filename, -4));
   $count++;
}


$folderPath="upload/$random_digit/";
		}
	}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.