• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.

Put Images in Folders Year,month,day

Yavin

Chevereto Noob
I saw some one ask this so thought I would look at it.

Code:
//this is my code to have images dumpped into folders based on year/month/day like 2010/4/13/image.png

$xyear = date('Y');
$xmonth = date('M');
$xday=date('d');
$xpath = "images/".$xyear."/".$xmonth."/".$xday."/";
define('DIR_IM',$xpath);

mkdir("images/".$xyear, 0700);
mkdir("images/".$xyear."/".$xmonth, 0700);

mkdir($xpath, 0700);

Open Config.php

Find "define('DIR_IM'"

And replace it with the code above, what it will do is create, or try and create the folder's for the current year, month and day of the month, it will then build that into the current DIR_IM as a path.

Any new uploads will then be put in those locations.

like www.imagehost.com/images/2010/Mar/25/myimage.png
 
Warning: mkdir() [function.mkdir]: File exists in /var/www/xxx/config.php on line 43

Warning: mkdir() [function.mkdir]: File exists in /var/www/xxx/config.php on line 44

Warning: mkdir() [function.mkdir]: File exists in /var/www/xxx/config.php on line 46

i have this problem :(
 
the dragon said:
Warning: mkdir() [function.mkdir]: File exists in /var/www/xxx/config.php on line 43

Warning: mkdir() [function.mkdir]: File exists in /var/www/xxx/config.php on line 44

Warning: mkdir() [function.mkdir]: File exists in /var/www/xxx/config.php on line 46

i have this problem :(

The folder's already exist, and your webserver is just telling you that, not sure how to ignore those warnings, happily mine does not warn like this. if you find a solution let me know.
 
Yavin said:
the dragon said:
Warning: mkdir() [function.mkdir]: File exists in /var/www/xxx/config.php on line 43

Warning: mkdir() [function.mkdir]: File exists in /var/www/xxx/config.php on line 44

Warning: mkdir() [function.mkdir]: File exists in /var/www/xxx/config.php on line 46

i have this problem :(

The folder's already exist, and your webserver is just telling you that, not sure how to ignore those warnings, happily mine does not warn like this. if you find a solution let me know.

I too am having this problem. Does anyone know a solution to this? If this can be resolved then this has been the mod I've been looking for!
 
You should write some "IF" that seeks if the folder already exist, if not then creates the folder.
 
Code:
if(is_dir("images/".$xyear)){
    //do something
}else{
    mkdir("images/".$xyear, 0755);
}


if(is_dir("images/".$xyear."/".$xmonth.$xyear)){
    //do something
}else{
    mkdir("images/".$xyear."/".$xmonth, 0755);
}

if(is_dir($xpath)){
    //do something
}else{
    mkdir($xpath, 0755);
}

Its not neat but it should work. just checks the see if the path is a DIR, if it is TRUE, then it does nothing, if it is FALSE then it makes the dir.

code is untested so let me know if you have issues.
 
Found a problem with this, dealing the the viewer code.

host.com/?v=myimage

the default code looks for the image name inside the images folder, and not inside these new folders that are created each day, I thought a solution would be to simply supply the full path to v so like ?v=2010/May/01/myimage.png but I cant seem to get this working.

Anyway else know what bit of code I need to be looking at ? or have a fix for it. ?

Also the above date , day and year code also needs to be applied to your thumbnail DIR_TM so that all thumbnails are put in the correct folders as well. or you will have TM issues.
 
the "?v" works by default in just one folder. In order to make this work you may (1) use db to store the folder information for each image or (2) provide the right "?v" after upload the file, this means that you have to change all the "mechanics" in "?v"
 
Rodolfo said:
the "?v" works by default in just one folder. In order to make this work you may (1) use db to store the folder information for each image or (2) provide the right "?v" after upload the file, this means that you have to change all the "mechanics" in "?v"

Yeah I was thinking ?v=2010/May/01/myimage.png

but while the code is english most of the variables and stuff is spanish or some other language so its kinda hard some times to track whats going on, you dont happen to know what files the code pertaining to the v paramater are ? in terms of viewing and displaying of the image passed to it ?
 
Is not too hard...

After this:
Code:
if ($modo==2 || $modo==3) {
    // INFORMACION (ANCHO, ALTO y PESO)
    if ($modo==2) {
        if ($_GET['v']) {
            $id = $_GET['v'];

you will find this:
Code:
$imagen = DIR_IM.$id;

So if id is "2010/May/01/myimage.png" the $imagen needs to fit in that... and you need to re-make the displays because "id" is for image files not directory+images in the original script.
got it?
 
I just can't get this, my images donesn't show at all .. :(

Code:
$imagen = DIR_IM.$id;
- don't understnd this part... :(
 
use this code

Code:
$xyear = date('Y');
$xmonth = date('M');
$xday=date('d');
$xpath = "images/".$xyear."/".$xmonth."/".$xday."/";
if(!is_dir($xpath)){
mkdir("images/".$xyear, 0777);
mkdir("images/".$xyear."/".$xmonth, 0777);
mkdir("images/".$xyear."/".$xday, 0777);
}
define('DIR_IM',$xpath);
 
small update to dedydamy code

Code:
$xyear = date('Y');
$xmonth = date('M');
$xday = date('d');
$xpath = "images/".$xyear."/".$xmonth."/".$xday."/";
if(!is_dir($xpath)){
    if(!is_dir("images/".$xyear)){
        mkdir("images/".$xyear, 0777);
    }
    if(!is_dir("images/".$xyear."/".$xmonth)){
        mkdir("images/".$xyear."/".$xmonth, 0777);
    }
    
    if(!is_dir("images/".$xyear."/".$xmonth."/".$xday)){
        mkdir("images/".$xyear."/".$xmonth."/".$xday, 0777);
    }
}

define('DIR_IM',$xpath);

There is another problem though. How can we use this new code while we have other old images in "/images" subfolder ? Maybe we can implement a check, if not found then search in /image ?
Any ideas about that ?
 
olejka2k said:
.....
$xmonth = date('M');
........

I changing this for :
$xmonth = date('m_M');
good sorting in folder


and, i put thumbs in Y-M-D folder too, i think its be convenient.
for this find
Code:
define('DIR_TH','thumbs/');
and replace
Code:
//Year-mounth-day for Thumbs
$xpath_thumbs = "thumbs/".$xyear."/".$xmonth."/".$xday."/";
if(!is_dir($xpath_thumbs)){
    if(!is_dir("thumbs/".$xyear)){
        mkdir("thumbs/".$xyear, 0777);
    }
    if(!is_dir("thumbs/".$xyear."/".$xmonth)){
        mkdir("thumbs/".$xyear."/".$xmonth, 0777);
    }
    
    if(!is_dir("thumbs/".$xyear."/".$xmonth."/".$xday)){
        mkdir("thumbs/".$xyear."/".$xmonth."/".$xday, 0777);
    }
}

define('DIR_TH',$xpath_thumbs);
//
 
Rodolfo said:
Is not too hard...

After this:
Code:
if ($modo==2 || $modo==3) {
    // INFORMACION (ANCHO, ALTO y PESO)
    if ($modo==2) {
        if ($_GET['v']) {
            $id = $_GET['v'];

you will find this:
Code:
$imagen = DIR_IM.$id;

So if id is "2010/May/01/myimage.png" the $imagen needs to fit in that... and you need to re-make the displays because "id" is for image files not directory+images in the original script.
got it?

Has anyone gotten this to work? i've attempted to do some edits to no avail?
 
Back
Top