If you're only uploading jpgs then you could also write this as
my ($name) = $path =~ /\w+\.jpg$/i;

since a regexp match returns an array, you're actually creating an array
with a single element ($name) and mapping it to the return from your match
$path =~ /etc/i;  you're match says "one or more word characters" [A-z0-9_]
followed by ".jpg" at the end of the string ($) and match case insensitively
(using the /i modifier)

In retrospect, Teddy's solution is probably cleaner but hopefully this will
be useful anyway...  this technique is best suited for grabbing various
elements out of a match ie. to grab the filename and extension you'd use:

my ($name, $ext) = $path =~ /(\w+)\.(\w+)$/i;

good luck.
-p


-----Original Message-----
From: Octavian Rasnita [mailto:[EMAIL PROTECTED]]
Sent: Sunday, December 22, 2002 10:17 AM
To: james lundeen; beginners-cgi
Subject: Re: File upload - probably simple..


Use regular expressions to get only the file name from the path.

You should use something like this:

$path =~ s/^.*[\\\/]//;

Teddy,
Teddy's Center: http://teddy.fcc.ro/
Email: [EMAIL PROTECTED]

----- Original Message ----- 
From: "james lundeen" <[EMAIL PROTECTED]>
To: "beginners-cgi" <[EMAIL PROTECTED]>
Sent: Sunday, December 22, 2002 12:56 AM
Subject: File upload - probably simple..


hey, do you have a solution to this?

I need to upload a file, but i just want the file name, not the entire
path.  Currently, it saves the actual file on the server as:

G:\ISIR\ISIR2002gallery\images\isir1.jpg   as the FILENAME!!!

i just want it to save as "isir1.jpg" or whatever the filename is for
the file that the user is uploading...

windows machine path for the file:
G:\ISIR\ISIR2002gallery\images\isir1.jpg

should end up as the following on the linux server:
/home/website1/html/images/isir1.jpg

Anyone with info on this, I'd really appreciate feedback.  Thanks!!!



__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to