CGI.pm filefield return is inconsistent between I.E and Opera/Firefox

E

evillen

Hi

If I have the following line:

my $url = $q->filefield('url','ignored','30');

in my cgi code, a file selector widget is created. I then choose a
file from somewhere on my network. The form is sent to my next cgi
script which displays the value of

$q->param("url")

The problem is that Internet Explorer displays the full relative path
of the file and the filename, e.g.

C:\pcb_data_dump\eco5_01GR_issue3.emp

however the same code run through Opera or Firefox will simply display
the filename with no path e.g.

eco5_01GR_issue3.emp

I really need the full relative path - how can I get hold of it with
Opera or Firefox?

Thanks for any help
Len
 
E

evillen

Your question is OT (not that you knew that) because the browsers were
simply programmed to behave differently. I dont have the CGI spec in
front of me, but I'm guessing that the part about the upload fields
didnt specify exactly how that should work, so you get different
implementations on different browsers.

You could use javascript to set a hidden field by extracting the value
of the file field like I've done on this page:

http://www.waveright.com/filefield.html

Here I've used a text field instead of a hidden field so you can see
the behavior.

But then your users have to have JS turned on unless you come up with
a workaround.

Hope this helps, and please find a more suitable newsgroup to send
followup questions to.

Todd W.

Your example at http://www.waveright.com/filefield.html only returns
the filename with no path when using Opera??
 
G

Gunnar Hjalmarsson

in my cgi code, a file selector widget is created. I then choose a
file from somewhere on my network. The form is sent to my next cgi
script which displays the value of

$q->param("url")

The problem is that Internet Explorer displays the full relative path
of the file and the filename, e.g.

C:\pcb_data_dump\eco5_01GR_issue3.emp

however the same code run through Opera or Firefox will simply display
the filename with no path e.g.

eco5_01GR_issue3.emp

Are you using the path to make the file available from a browser on the
client machine? Odd. You'd better upload the file to the server machine,
and make it available from there if desirable.
 
E

evillen

Are you using the path to make the file available from a browser on the
client machine? Odd. You'd better upload the file to the server machine,
and make it available from there if desirable.

Yes I want to make the existing location available - this is for a
secure intranet. Perhaps uploading locally would be more safer but I
was hoping to avoid duplication of files.
 
P

Peter J. Holzer

If I have the following line:

my $url = $q->filefield('url','ignored','30');

in my cgi code, a file selector widget is created. I then choose a
file from somewhere on my network. The form is sent to my next cgi

The <input type="file" /> element is intended to upload the *contents*
of a file, not its filename. So when your browser sends the form, it
includes the complete content. It may also include the filename, but
this is not required (although recommended) by RFC 1867. What a "file
name" is is not defined, so it's hardly surprising that browsers
differ.

The problem is that Internet Explorer displays the full relative path
of the file and the filename, e.g.

C:\pcb_data_dump\eco5_01GR_issue3.emp

however the same code run through Opera or Firefox will simply display
the filename with no path e.g.

eco5_01GR_issue3.emp

I really need the full relative path - how can I get hold of it with
Opera or Firefox?

What use would a path on C:\ be on any other computer?

hp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top