Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renaming files using a script

Status
Not open for further replies.

monkeywithagun

Technical User
Jan 9, 2005
5
US
I've been using cgi-lib.pl (a library for parsing input), and i'm quite happy with it.

I've gotten almost everything i want to work with so far. Using cgi-lib.pl and code like that which is found at: I can upload a file.

The problem comes from the fact that it uploads the file with a new "secure" name. No big deal, I though, I'll just rename it. But i havn't been able to get that to work. The code i entered was:

rename(images/$cgi_data{'upfile'},images/$cgi_cfn{'upfile'});

I'm assuming that line is wrong, because everything else works. Could someone please help me fix it?

P.S. $cgi_data{'upfile'} and $cgi_cfn{'upfile'} are the secure and origonal file names, respectivly.
 
[aside]You should be using CGI.pm which AFAIK supercedes cgi-lib[/aside]

Are you getting any error messages? If you print these two values prior to rename, are you getting the proper values displayed?

Rename only works on the same drive IIRC, are these both on the same logical disk?

Might just be quotes
Code:
rename("images/$cgi_data{'upfile'}","images/$cgi_cfn{'upfile'}");

HTH
--Paul

cigless ...
 
It was just a matter of quotes, thanks Paul!

As far as CGI.pm goes, I'm not sure if it is installed on my server (I don't own the tower, or even have a shell account). I tried implimenting a few scripts which called on it, but they didnt work.
 
If you have Perl installed you have CGI.pm. Its part of the core Perl distribution. CGI.pm is recommend well over and above cgi-lib.pl, if only for the simple reason of security.

cgi-lib.pl is now over 6 years old, and has little or no maintenance on it. CGI.pm has been very carefully crafted by Lincoln Stein, to be as robust and secure as possible. It is also regularly maintained as the world changes.

Barbie
Leader of Birmingham Perl Mongers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top