Forum Moderators: coopster & phranque

Message Too Old, No Replies

CGI Passing file name

CGI <input type="file"> passing name

         

rajatgarg

6:28 pm on Jul 19, 2004 (gmt 0)

10+ Year Member



Hi all,

I am in trouble and I am trying to figure out the way to get the solution, but to no use. Kindly help!

I use <input type ="file" name = "testfile">

and then in cgi script, I try to access it by:
$in{testfile} but I get the dump of whole file. I just want the filename, how to do it?

I have used method = post, enctype = multiform-data.....
and cgi-lib.pl

Please help ...

Regards,
Rajat Garg

kalos

8:32 pm on Jul 19, 2004 (gmt 0)

10+ Year Member



$in{testfile}->{'filename'} should do the trick although it is untried (by me). I tend to do this a slightly different manner (not using CGI to handle it) so this is a stab in the dark.

lexipixel

8:11 am on Jul 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This help at all?

$testfile = lc($query->param("testfile"));
$testfile =~ s/.*[\/\\](.*)/$1/;

rajatgarg

5:21 pm on Jul 20, 2004 (gmt 0)

10+ Year Member



Thanks for the help.
I was actually using cgi-lib.pl, and using $in{name} prints the file. In case of CGI.pm, $in{'name'} returns the file name, which I wanted. Also, I liked the hash %in provided by cgi-lib.pl....

so I mixed the above and used Vars member of CGI.pm to get the hash %in, and used $cgi->{'name'} to get the file handle....

not a great work around but suits me....

thanks a ton,

rajat garg