Here's a couple of guesses:
- You didn't use -w
- You didn't use strict
- You didn't check the return code on your open
- And here's my bet: your form tag does not specify enctype="multipart/form-data"
The last one can directly cause the problem you've mentioned. Typically, when you have an input type of file, the form tag and input tag should look something like the following:
<form method="post" action="somescript.cgi" enctype="multipart/form-da
+ta">
<input type="file" name="file">
The enctype in this case specifies that the form data be sent in MIME format. This is the ONLY way that your system can parse out the upload contents. However, the value associated with the parameter "file" is something like "C:\windows\desktop\somefile.txt". Trying to open this filehandle directly when using strict will actually kill your script. However, if you try to open the filehandle directly on a local machine without strict, you'll actually get the file you are looking for, because Perl finds the path to the file. CGI.pm actually takes the file and stores it on the server and returns the param as a filehandle to the stored file. (I know I didn't explain this well, I'm a bit tipsy :)
See this node for a file upload script that I fixed up for another Monk. It may help you get started in the right direction.
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just go the the link and check out our stats.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.