Long file name or special symbol file name support problem Long file name or special symbol file name support problem
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Long file name or special symbol file name support problem

Started by mancool, September 09, 2004, 10:07:18 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mancool

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??

Joachim Müller

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

mancool

Quote from: GauGau 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

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

jdcdesigns

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

//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