neversaint has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

In CGI.pm all other method in form (e.g. radio button, list) enable us to set default value.
Is there any way to do it for Upload (filefield)? If not, what are the alternatives?

I tried the following snippet but doesn't work:
strong('Upload Your Data: '), br filefield( -name => 'upload', -size => 28, #I'm running on Linux server -default => '/path/tomyfile/test.txt' ), br


---
neversaint and everlastingly indebted.......

Replies are listed 'Best First'.
Re: Setting Default File for Upload in CGI.pm
by Corion (Patriarch) on Sep 20, 2007 at 10:14 UTC

    You can set the default all you want, but the browsers will clear it. This is a security measure so a website cannot trick you into uploading /etc/passwd and /etc/shadow, for example.

Re: Setting Default File for Upload in CGI.pm
by mhearse (Chaplain) on Sep 20, 2007 at 11:35 UTC
    You might be able to do that using Javascript.
    <head> <script> function screenload() { theform=window.document.forms[0]; theform.upload_form_name.value=DEFAULT_VALUE; } </script> </head> <body onload=screenload()>