Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Template Shares (http://www.bvlist.com/forumdisplay.php?f=26)
-   -   Rename on upload(ts gallery) (http://www.bvlist.com/showthread.php?t=4244)

saggy00 13th January 2010 21:23

Rename on upload(ts gallery)
 
Hello guyw. I have tsse 5.4.1 and i have installed gallery plugin. The problem is the users have uploaded plenty of pictures and now is difficult to find an easy name for your pictures. How can i rename the photos on upload and give them a number(1,2,3...)which(the number) will ascend???

Phogo 16th January 2010 16:20

PHP Code:

  //This line assigns a random number to a variable.  You could also use a timestamp here if you prefer. 
$ran rand () ;

 
//This takes the random number (or timestamp) you generated and adds a . on the end, so it is ready of the file extension to be appended.
$ran2 $ran.".";

  
//This assigns the subdirectory you want to save into... make sure it exists!
$target "images/";  //This combines the directory, the random file name, and the extension
$target $target $ran2.$ext

PHP Code:

if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
{
    echo 
"The file has been uploaded as ".$ran2.$ext;

else
{
    echo 
"Sorry, there was a problem uploading your file.";
}
   
?> 

Try that somewhere....

joeroberts 16th January 2010 16:28

you well want to run a check to make sure that # dose not exsest already!
some thing like this
Code:

$cnt = 1;
do {
if(!is_file($target = $target . $ran2.$ext;))$cnt = 0;
} while ($cnt > 0);


saggy00 16th January 2010 18:39

Thanks guys!! I'll try it


All times are GMT +2. The time now is 02:51.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.