Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

file upload using Embperl

by Anonymous Monk
on Nov 15, 2011 at 14:01 UTC ( #938179=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I am getting form data values as null in %fdat varible in EmbPerl, if we go for file upload and form property enctype="multipart/form-data".
Without enctype="multipart/form-data" and submit the form, can see the form values in %fdat variable. Can anyone tell me why its giving undef in the case of enctype
Thanks,

Comment on file upload using Embperl
Re: file upload using Embperl
by MidLifeXis (Prior) on Nov 15, 2011 at 14:09 UTC

    Please include, if possible, a short chunk of code that demonstrates the issue that you are seeing. Place it between <code>...</code> tags. Also include data that you use, what you want to see, and what you actually see, if appropriate.

    --MidLifeXis

      Hi,
      Sorry ....
      Here is the HTML form informations
      <form action="load.html" name="form1" method="post" enctype="multipart +/form-data"> <table> <tr class="cell4"> <td>Select EXCEL rate sheet</td> <td><input type="file" name="file" value=""></td> </tr> <tr class="cell3"> <td>&nbsp;</td> <td><input type="submit" name="upload" value="upload"></td> </tr> </table> </form>

      and Embperl code used is
      if((defined $fdat{file} && $fdat{file}) && $fdat{upload}) { $filename = "/tmp/sample.txt"; open (FILE, "> $filename") || die("open failed: $!"); while (read($fdat{file}, $buffer, 32768)) { print FILE $buffer || die("print test: $!"); } close FILE || die("close test: $!"); }
      If we remove enctype="multipart/form-data" form property, can see the form data (filename) after submiting the page.
      includng enctype="multipart/form-data" in form will give undef filename. Any idea?
      thanks

        Compare your code to embperl upload ( Embperl-2.4.0/test/html/upload.htm )

        In fact, I would use Embperl-2.4.0/test/html/upload.htm to figure things out

        Testing for ref $fdat{upload} seems simplest

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://938179]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2014-08-22 08:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (151 votes), past polls