Post by mykingla » Mon Dec 08, 2008 11:03 am

I'd like to change the file name when I use the upload class to upload the file.

How should I do?  :(

New member

Posts

Joined
Wed Dec 03, 2008 10:45 am

Post by jty » Mon Dec 08, 2008 11:35 am

The only way I know how to do that is to change the filename in your PC before uploading
I don't believe Open Cart has the feature to change filenames

If you have a bulk lot of files and you want to add/change something standard about them, go google and find Advanced Renamer. It allows you to bulk change filenames.

eg. your files are blue_balls_large, pink_balls medium, green_balls_small
You can use advanced renamer to change it to be balls_large_blue, balls_medium_pink, balls_small_green.jpg etc etc. in bulk lot

or search google for a file renaming tool. There are free ones out there.

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by mykingla » Mon Dec 08, 2008 12:28 pm

Really?

Maybe I can modify the upload class.

New member

Posts

Joined
Wed Dec 03, 2008 10:45 am

Post by Qphoria » Mon Dec 08, 2008 12:51 pm

depending on what you want to rename, you could change it here:

/library/filesystem/upload.php

Code: Select all

function save($key, $file) {
	[color=red]$file = rand(5, 15);	[/color]
	if (file_exists($file)) @unlink($file);
	$status=@move_uploaded_file($_FILES[$key]['tmp_name'], $file);
	if ($status) @chmod($file, 'a+r');
	return $status;
}	
That would rename the file to a random number. Depending on what you want to change it to, will depend on where you make the change

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by mykingla » Mon Dec 08, 2008 1:48 pm

I want to use the time()+microtime() to replace the random digit.

New member

Posts

Joined
Wed Dec 03, 2008 10:45 am

Post by Qphoria » Mon Dec 08, 2008 1:52 pm

Code: Select all

function save($key, $file) {
	[color=red]$file = ($file) . (time() + microtime());[/color]
	if (file_exists($file)) @unlink($file);
	$status=@move_uploaded_file($_FILES[$key]['tmp_name'], $file);
	if ($status) @chmod($file, 'a+r');
	return $status;
}	

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 7 guests