• 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.

Keep basename in the image upload name

Rodolfo said:
Clean the var, is the obvious fix.

Hi,
please tell me where to clean the var - my fix if in pic to upload is a blank - in class.uploade.php:

search for:
Code:
$destination = $this->img_upload_path.'temp_'.$this->source["name"];
insert below:
Code:
$destination = str_replace(' ', '_', $destination);

for me I replace a blank widh underscore.

and 2nd search for (in function randomFile() ):
Code:
$folder = ($folder == '') ? './' : $folder;
and insert below:
Code:
$original_name = str_replace(' ', '_', $original_name);

I replace
Code:
$image_uploaded_path = $this->randomFile($this->img_upload_path, $this->extension);
width:
Code:
$image_uploaded_path = $this->randomFile($this->img_upload_path, $this->extension, $this->source["name"]);

because I make my thing to keep the original filename in the function randomFile()

If there is uploaded a file with the same name and if someone wish not to create a file with a random number but like
origname_1.jpg,
origname_2.jpg
...
then you can do this in function randomFile():

Code:
    private function randomFile($folder = '', $extension = '', $original_name = '')
    {
        $folder = trim($folder);
        $folder = ($folder == '') ? './' : $folder;
        
        $original_name = str_replace(' ', '_', $original_name);
        $purname = substr($original_name,0,strpos($original_name,"."));
        
        $filepath = $folder . $purname .'.'. $extension;
        $t = 0;
        while(file_exists($filepath)) {
            $filepath = $folder . $purname ."_$t.". $extension;
            $t++;
        }
        return $filepath;
    }

This works with version 2.0.18 and class.upload.php 1.8
 
Back
Top