Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Long file name or special symbol file name support problem  (Read 4105 times)

0 Members and 1 Guest are viewing this topic.

mancool

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 62
Long file name or special symbol file name support problem
« on: September 09, 2004, 10:07:18 am »

When I batch upload some kind of JPEG file. The file name is too long or special symbol (such as []{} something like that), after it gen, into thumb photo, the error message will so out as following,

"Warning: getimagesize(albums/CM/thumb_kazoku%5B1%5D.jpg): failed to open stream: No such file or directory in X:\XXX\XXX\XXX\include\functions.inc.php on line 1065"

The file name is ~~~ thumb_kazcku[1].jpg

If so, I have to beware to upload such file next time??
« Last Edit: September 10, 2004, 05:44:47 am by kegobeer »
Logged

Joachim Mller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Long file name or special symbol file name support problem
« Reply #1 on: September 09, 2004, 10:07:38 pm »

I'm not sure what to make out of your posting (language issue), please post more details. As a rule of thumb, you should only use alphanumeric chars (only use the underscore "_" and dash "-" as special chars) as filename. You can edit what chars to replace: edit "Characters forbidden in filenames" in coppermine config accordingly.

Joachim
Logged

mancool

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 62
Re: Long file name or special symbol file name support problem
« Reply #2 on: September 10, 2004, 05:18:12 am »

I'm not sure what to make out of your posting (language issue), please post more details. As a rule of thumb, you should only use alphanumeric chars (only use the underscore "_" and dash "-" as special chars) as filename. You can edit what chars to replace: edit "Characters forbidden in filenames" in coppermine config accordingly.

Joachim

I find it. It is symbol problem. I am very sorry to interrupt you.
Logged

jdcdesigns

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Long file name or special symbol file name support problem
« Reply #3 on: October 01, 2004, 06:54:59 pm »

I had this same problem.  The thumbnails and photos were not displaying correctly if the filename was too long, or invalid characters.  I also found maintaing the list of "forbidden" characters to cumbersome for me. I really just wanted to limit file names to ONLY alpha-numeric characters and underscores. Especially since I had a problem with people uploading files from different countries where character encoding was different.

So the below code will change a file name like:
.JPG to _1096647866.JPG
Or file names like Mary's First Birthday.jpg to Marys_First_Birthday.jpg

Code: [Select]
//Open includes/db_input.php
//Around Line 275
//Find
        if (!preg_match("/(.+)\.(.*?)\Z/", $picture_name, $matches)) {
            $matches[1] = 'invalid_fname';
            $matches[2] = 'xxx';
        }

//After it add:

if (strlen($matches[1]) > 30) $matches[1] = substr($matches[1],0,30); //replace "30" with maximum desired string length
$matches[1]=str_replace(" ","_",$matches[1]);  //First replace all spaces with underscore
$matches[1]=preg_replace('/[^a-zA-Z0-9_-]*/','', $matches[1]);  //remove all non-alpha-numeric characters
if(strlen($matches[1])<2) $matches[1].= "_".time(); //name may have been all symbols, so add time to make unique name

Logged
Pages: [1]   Go Up
 

Page created in 0.023 seconds with 19 queries.