ADPIC retain file name + random number

ClassiBase classifieds script Forums General help ADPIC retain file name + random number

This topic contains 3 replies, has 2 voices, and was last updated by  Clifford Enoc 1 year, 10 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2576 Reply

    Hello,

    Is is possible to maintain the filename of the image then append the random number.
    Example: the uploaded pic filename is:
    this-image-describes-this-pic.jpg

    when uploaded will convert to:

    this-image-describes-this-pic-78805a221a988e79ef3f42d7c5bfd418.jpg

    or

    78805a221a988e79ef3f42d7c5bfd418-this-image-describes-this-pic.jpg

    I know the image filename maybe quite long but I’ve seen images that long.
    We can also shorten the random number to say only 18 char.

    I’ve looked at the code at /sys/app/models/Adpics.php
    and cannot determine where to modify or change.

    Thank you.

    #2582 Reply

    ClassiBase
    Keymaster

    Hello,

    We like the idea that you suggest. Previously it was retaining image name but on simple names like “image.jpg” it was checking too many names if they exist then it would suggest other name by increasing integer at the end like “image-18.jpg” .

    This was problem with browser caching for example if image deleted from server but exists on users’ browser cache then it will show old image instead of new one.

    In short you can disable image name randomization by changing following line in upload() model in /sys/app/models/Adpics.php file

    $upload_config['encrypt_name'] = true;

    to

    $upload_config['encrypt_name'] = false;

    Try it and let us know if it works for you.

    Also we will look for better solution for this and add it to next release if we find one.

    #2583 Reply

    ClassiBase
    Keymaster

    In case above didn’t work then edit /sys/helpers/Upload.php file edit function setCheckFilename($path, $filename) change following line as well:

    if(strlen($this->getRawName($filename)))
    {
    	$filename = $this->_randomStr() . $this->file_ext;
    }

    to

    if(!strlen($this->getRawName($filename)))
    {
    	$filename = $this->_randomStr() . $this->file_ext;
    }
    #2608 Reply

    Wow, it works thanks a lot!

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: ADPIC retain file name + random number
Your information: