News:

CPG Release 1.6.28
added submissions from {406man}
cleaned up a few PHP (8.4) deprecations
fixed PHP deprecation in calendar
removed security vulnerability
(please upgrade when possible)

Main Menu

changing filenames

Started by Oasis, September 25, 2003, 05:08:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Oasis

Hi, is there a way I could make coppermine change the filename when uploading the photo? you see, apache doesn't support chinese character filenames very well, and my users are mostly chinese. if they upload photos with chinese filenames they will probably not show up on most browsers. I saw this other photo album where the uploaded files had their names changed on upload. Is this possible to do?
Pixnet Gallery: http://www.pixnet.net
iNSiGNiA Weblog: http://www.jayliu.org

Joachim Müller

have you tried that? I think coppermine already changes the filenames...

GauGau

Oasis

nope... at least it doesn't seem to... the filenames remain chinese, and worst of all the last "g" in .jpg gets removed if they are using xp_publish for uploading. so if for example ABCD is two chinese words(chinese is double byte) and the filename is ABCD001.jpg, it gets uploaded into ABCD001.jp and the thumbnail becomes thumb_ABCD001.jp and normal_ABCD001.jp

What i would like is for the program to rename it to a different name, maybe using the time of upload or something similar.... so that ABCD001.jpg will be uploaded as 12301209.jpg or any filename that doesn't have chinese characters..
Pixnet Gallery: http://www.pixnet.net
iNSiGNiA Weblog: http://www.jayliu.org

Oasis

here is an example of what happens..

http://photo.enctu.org/index.php?cat=10012

the photo doesn't show up unless you have "send URL as UTF-8" disabled. And sometimes it doesn't work even if it is disabled. I think this is a problem with apache, but they don't seem to think it's a bug (they probably don't understand the problem since they're not familiar with chinese) and I don't think they intend on fixing it.

EDIT: oops... the user deleted the file.. here is another one I uploaded myself... It just shows up as a broken picture.
http://photo.enctu.org/thumbnails.php?album=35&page=1
You can see the filename, and the file IS there on the server. It just won't show up on the browser.
Here is the photo view: http://photo.enctu.org/displayimage.php?album=35&pos=9
Pixnet Gallery: http://www.pixnet.net
iNSiGNiA Weblog: http://www.jayliu.org

Joachim Müller

hm, this'll require some looking into it. I'll keep this on my todo-list; please post here if you find a solution for this problem...

GauGau

Oasis

does this mean that there isn't a way I could edit the code so that it would automatically change the filename on upload?

It's the only workaround I can think of
Pixnet Gallery: http://www.pixnet.net
iNSiGNiA Weblog: http://www.jayliu.org

Joachim Müller

of course this is the solution - but that's not that easy: you'll have to make sure that a file with the "renamed name" doesn't already exist. If you're a little familar with PHP I suggest you give it a shot :wink:

GauGau

Oasis

OK! It worked, I changed $matches[1] to time() and if it uploads too fast (as in more than one photo a second) and gets an identical name it adds the ~$nr++ just as it did when it got identical filenames.
Pixnet Gallery: http://www.pixnet.net
iNSiGNiA Weblog: http://www.jayliu.org

Oasis

Still one tiny problem though..

files with chinese filenames still get the last "g" chopped of their file extensions. They show up fine on the website, so I guess IE realizes they're images, but if they download the pics back to their computers they're gonna have to change the extension before they can open it. Also, I'm not sure if the .jp extension is gonna suit all browsers.

Does anyone know what may be causing this? I looked and relooked at the code and I am getting dizzy but I still can't figure out why
Pixnet Gallery: http://www.pixnet.net
iNSiGNiA Weblog: http://www.jayliu.org