By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,903 Members | 1,067 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,903 IT Pros & Developers. It's quick & easy.

hidden variables with EncType="multipart/form-data"

P: 30
Not able to pass variables data:

Hello .. Im building a form that uploads files with encType="multipart/form-data" but on the same form I need to pass other variables with hidden fields.

The files are uploading fine but Im not getting the values of the hidden fields,

How can I get hidden field values along with uploaded files in the same form..??

This is my form code:


Expand|Select|Wrap|Line Numbers
  1. <form action="upload_file.pl" encType="multipart/form-data" method="Post">
  2. <input type=file name="FILE">
  3. <input type="hidden" name="URL" value="$URL">
  4. <input type="hidden" name="Alias" value="$Alias">
  5. <INPUT type=submit value="Upload File">
  6. </form>
Im attaching the perl script that handles the upload under the name of Upload_Perl_Script.txt

Thanx beforehand
Virtual Web
Attached Files
File Type: txt Upload_Perl_Script.txt (11.9 KB, 636 views)
Jul 26 '09 #1
Share this Question
Share on Google+
4 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
@virtualweb
I see your above form code and I have a question. Is that code being sent to the browser by a Perl script, or is it just an HTML file? If it is a Perl script, can we see it as well?

If they are not set, then I assume there is an issue with your variables being set as shown above and you should look into that first to ensure they are being set.

Regards,

Jeff
Jul 26 '09 #2

KevinADC
Expert 2.5K+
P: 4,059
That script is written to get only numbered file upload fields. How are you getting $URL and $ALIAS into that form you posted anyway?
Jul 26 '09 #3

KevinADC
Expert 2.5K+
P: 4,059
assuming your form is populated correctly:

change this:

Expand|Select|Wrap|Line Numbers
  1.     use CGI; 
  2.  
  3.     $max_num_files  ||= 1;
  4.     $Data         ||= $ENV{'DOCUMENT_ROOT'};
  5.     undef @bad_extensions if @good_extensions;
change to:

Expand|Select|Wrap|Line Numbers
  1.     use CGI; 
  2.  
  3.     $max_num_files  ||= 1;
  4.     $Data         ||= $ENV{'DOCUMENT_ROOT'};
  5.     undef @bad_extensions if @good_extensions;
  6.     $alias = $req->param("Alias");
  7.     $url = $req->param("URL");
  8.  
now you use $url and $alias in the perl script however you need them.
Jul 26 '09 #4

P: 30
Hi KevinADC:

I appreciate your help.. I had tryed your solution prior to posting for help here, and it didnt work. This made me think that uploading a file was different than passing text as a variable.

Second time around worked just fine..

Thanx a million
VirtualWeb
Jul 26 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.