XUpload - rename files to unique id

XUpload related questions

Moderator: admin

Posts: 9
Joined: Jun 23, 2007 1:12 pm

rename files to unique id

#1 Postby tommy » Jun 23, 2007 1:24 pm


I've tested xupload (Free version), and I'm really impressed!
I think I'll order the pro version, but I have one problem:

What I have to change in upload.cgi to rename _every_ file to a (really) unique id (for example: file.ext should be renamed to 2DQ4MHk8YVD28TX1)

User avatar
Posts: 2182
Joined: Mar 22, 2006 1:39 pm
Location: UFO Lab

#2 Postby PilgrimX182 » Jul 04, 2007 7:52 am

It's easy hack. In upload.cgi find

Code: Select all

my ($fn,$ext) = ($1,$2);

and add below it:

Code: Select all

my @range = ('0'..'9','A'..'Z');
$fn = join '', map $range[rand($#range+1)], 1..10;

this will set filename as random string of 10 chars(alphanumeric,uppercase) with no extension.

Posts: 9
Joined: Jun 23, 2007 1:12 pm

#3 Postby tommy » Jul 21, 2007 5:23 pm

I purchased the pro version now, and I added the code below

Code: Select all

my ($fn,$ext) = .........
and it works fine!
Thanks for your help!


Posts: 3
Joined: Jul 31, 2007 7:05 pm

#4 Postby virtuexru » Jul 31, 2007 7:06 pm

Can you clarify which part of this needs to be changed??

Code: Select all

   my ($fn,$ext) = $filename=~/^(.+)\.(.+)$/;
   $fn=$filename unless $filename=~/\./;

   $fn = substr($fn,0,$c->{max_name_length});

Return to “XUpload”

Who is online

Users browsing this forum: No registered users and 0 guests