• Welcome to the Chevereto User Community!

    Here, users from all over the world come together to learn, share, and collaborate on everything related to Chevereto. It's a place to exchange ideas, ask questions, and help improve the software.

    Please keep in mind:

    • This community is user-driven. Always be polite and respectful to others.
    • Support development by purchasing a Chevereto license, which also gives you priority support.
    • Go further by joining the Community Subscription for even faster response times and to help sustain this space

Store images by date folders

Stepashka

Chevereto Member
Need help with the code.
I modified the script a little to store images by date folder, everything work fine except the images/thumbs/
the folder is created but nothing is uploaded to there

Here's what i did:

in condig.php

$folderdate = date("d.m.y");

$config['folder_images'] = 'images/' . $folderdate;
$config['folder_thumbs'] = 'images/thumbs/' . $folderdate;

in class.upload.php

public function process()
{

if (!is_dir('$img_upload_path')) {
mkdir($img_upload_path , 0777);
chmod($img_upload_path, 0777);
}

if (!is_dir('$thumb_upload_path')) {
mkdir($thumb_upload_path , 0777);
chmod($thumb_upload_path , 0777);
}
 
I don't know if it will change anything, but here some correction to your code:

First of all, you should activate the error_reporting in chevereto configs, so if you have an error, you will see it

find
PHP:
$config['error_reporting'] = false; // Values: true|false
replace with
PHP:
$config['error_reporting'] = true; // Values: true|false

Chevereto is always ending path variables with an / so... in config you must do the same...
PHP:
$config['folder_images'] = 'images/' . $folderdate . '/';
$config['folder_thumbs'] = 'images/thumbs/' . $folderdate . '/';


PHP:
// a php var should not be between '' it can be between "", but it is not recommended, only text should be. 
// you should be using file_exists instead of is_dir (doesn't change anything... but using the rights functions is always better)
// also $img_upload_path and thumb... are class variables, you can not access them using the normal way
// you need to put $this-> before to specify i'm using this class, and then the variable name without the ($)
if (!file_exists($this->img_upload_path)) {

    //mkdir already chmod the directory when creating it. 
    // the third parameters tell mkdir to create the directories recursively instead of stopping if it doesnt find one.
    mkdir($this->img_upload_path , 0755, true);
}

if (!file_exists($this->thumb_upload_path)) {
    // giving the permissions set 0777 is not recommended for security reasons, listing and downloading all images of your folder 
    //become much easier for an hacker
    mkdir($this->thumb_upload_path , 0755, true);
}
 
Than it's comes out with double splashes.


The code below fixed the thumbs isuue. Thanks for the detailed answer.
// a php var should not be between '' it can be between "", but it is not recommended, only text should be.
// you should be using file_exists instead of is_dir (doesn't change anything... but using the rights functions is always better)
// also $img_upload_path and thumb... are class variables, you can not access them using the normal way
// you need to put $this-> before to specify i'm using this class, and then the variable name without the ($)
if (!file_exists($this->img_upload_path)) {

//mkdir already chmod the directory when creating it.
// the third parameters tell mkdir to create the directories recursively instead of stopping if it doesnt find one.
mkdir($this->img_upload_path , 0755, true);
}

if (!file_exists($this->thumb_upload_path)) {
// giving the permissions set 0777 is not recommended for security reasons, listing and downloading all images of your folder
//become much easier for an hacker
mkdir($this->thumb_upload_path , 0755, true);
}
 
sounds really an good idea . is it possible to have images on Monthly folders ? if yes , would anybody share the whole code step by step ?

Regards
 
Don't worry, 2.1 will store everything in datefolders 😉
 
Back
Top