Hi!
I've got a nifty little file upload script that works just fine in IE. It's a wonderful thing. But I just tried it in Netscape and while it IS saving the file to the directory specified, it's also bringing up a "save as..." box so the user can save the upload.cgi to their harddrive. It's doing that instead of loading the HTML code as specified by the &subs which basically load a page saying that the file was uploaded. I've not run into this before and since most of the users I'm going to be dealing with HAVE to use Netscape, it's a problem I need a solution to.
Here's the code I'm using on the .asp page for the form:
<form method=post action=upload.cgi name=upload_epic enctype="multipar
+t/form-data">
<input type=file size=20 name=upload>
<br><input type=submit value=submit>
</form>
And here's the code for the script (not entirely my own and minus the subs containing HTML code):
#!/usr/local/bin/perl
use CGI qw/:standard/;
use File::Basename;
&print_return_page_top;
print_results();
sub print_results {
my $q = new CGI;
my $length;
my $file = $q->param('upload');
my $time = time;
if (!$file) {
print "No file uploaded.";
return;
}
($base,$path,$type) = fileparse($file,'\..*');
my $uploaded_path = "\\path\\to\\uploaded_files\\";
$uploaded_path .= $base;
$uploaded_path .= "_";
open FILE, ">$uploaded_path$time$type";
binmode FILE;
while ($bytesread=read($file,$buffer,1024)) {
print FILE $buffer;
}
print h2('Success!'),"$file has been uploaded.";
}
&print_return_page_bottom;
If anyone could give me some insight as to why Netscape is puking this back up, it would be much appreciated. Thanks!
_____________________________________________________mojobozo
word (wûrd)
interj. Slang. Used to express approval or an affirmative response to
something. Sometimes used with up. Source
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.