• 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

Not hard to be done, a single file must be edited on upload.php but you will need to always keep that change once you upgrade the script.

Are you ok with that?
 
Rodolfo said:
Not hard to be done, a single file must be edited on upload.php but you will need to always keep that change once you upgrade the script.

Are you ok with that?


ok, show me how to do that plz
 
This will let you have NAME_random.ext in the uploaded files.

Open includes/classes/class.upload.php and find this:

PHP:
$image_uploaded_path = $this->randomFile($this->img_upload_path, $this->extension);

and replace with this:
PHP:
if($this->is_remote) {
	$original_name = basename($this->source);
} else {
	$original_name = $this->source["name"];
}			

$image_uploaded_path = $this->randomFile($this->img_upload_path, $this->extension, substr($original_name, 0, -4));

Find this:
PHP:
	private function randomFile($folder = '', $extension = '')
	{
		$folder = trim($folder);
		$folder = ($folder == '') ? './' : $folder;
		$filepath = $folder . generateRandomString(5) .'.'. $extension;
		while(file_exists($filepath)) {
			$filepath = $folder . generateRandomString(5) .'.'. $extension;
		}
		return $filepath;
	}

And replace with this:
PHP:
	private function randomFile($folder = '', $extension = '', $original_name = '')
	{
		$folder = trim($folder);
		$folder = ($folder == '') ? './' : $folder;
		$filepath = $folder .generateRandomString(5) .'.'. $extension;
		while(file_exists($filepath)) {
			$filepath = $folder . $original_name.'_'.generateRandomString(5) .'.'. $extension;
		}
		return $filepath;
	}


Tested on dev.chevereto.com and it works.
 
izam2 said:
it works!
very good job Rodolfo!

Cool =)

nmt12 I don't have the remote idea on how his system works. But I think that is just you doing wrong.
 
Rodolfo !!! You had mistake !!

You said replace this !!

Code:
private function randomFile($folder = '', $extension = '')
    {
        $folder = trim($folder);
        $folder = ($folder == '') ? './' : $folder;
        $filepath = $folder .generateRandomString(5) .'.'. $extension;
        while(file_exists($filepath)) {
            $filepath = $folder . $original_name.'_'.generateRandomString(5) .'.'. $extension;
        }
        return $filepath;
    }

It not working !!!

It must be like this

Code:
private function randomFile($folder = '', $extension = '', $original_name = '')
    {
        $folder = trim($folder);
        $folder = ($folder == '') ? './' : $folder;
        $filepath = $folder . $original_name.'_'.generateRandomString(5) .'.'. $extension;
        while(file_exists($filepath)) {
            $filepath = $folder . $original_name.'_'.generateRandomString(5) .'.'. $extension;
        }
        return $filepath;
    }

And it working !!! Tested succeed
 
I had found a big error with this MOD !!

When we upload a image with name has space ( Ex : AB CD.png ) - it will can not uploaded and display notice

Not found (404)
The server can't find the requested page.

Hix, how we can fix it ???
 
Rodolfo said:
original_name

I don't think 'cause is original_name var !!!

In this case ( Keep basename in the image upload name succeed ) - When you upload multi pic , the page will display is http://sitename.com/?uploaded ----> not error ( pics upload succeed , and link good )

And when you upload just one pic , when we uploaded a pic has name AB CD.png , the page will display is http://sitename.com/?v=AB%20CD_MDs0h.png ---> it will error , 'cause the link of pic is http://sitename.com/images/AB CD_MDs0h.png .

So , we just fixed the page display when uploaded just 1 pic like upload multi pic

So i change some code in peafowl.php by this way :

1/ in peafowl.php - find this
Code:
if(data.filesUploaded==1) {
                                        window.location = "<?php echo __CHV_RELATIVE_ROOT__; ?>?v="+ImagesUp;

2/ Replace it by this

Code:
if(data.filesUploaded==1) {
                                        window.location = "<?php echo __CHV_RELATIVE_ROOT__; ?>?uploaded";

3/ In content/themes/peafowl/view.php , find this
Code:
<div class="input-item"><label for="viewer-link"><?php show_lang_txt('txt_show_viewer_link'); ?>:</label> <input type="text" id="viewer-link" value="<?php show_img_viewer(); ?>

replace it by this
Code:
<!-- <div class="input-item"><label for="viewer-link"><?php show_lang_txt('txt_show_viewer_link'); ?>:</label> <input type="text" id="viewer-link" value="<?php show_img_viewer(); ?>" /></div> -->

And problem will be fixed , all error of this mod will fixed

Tested succeed in my site
 
Back
Top