• 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

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