Hello PMs,
I return for more quidance. I want to build a quick form to upload a file (and back up the file that was there before) and then go on to another form. Can I do this in one file? I just have the feeling I'm going down the wrong road. I will note that addind PMs or Mods is quite a process (I don't have control/access), so if you have a bare bones solution other than mine, I'm all keys. It will be ID/pass protected, but I'm all set there (didn't include it as it's not part of my question)
Here is what I have so far (psedo-ish) and I noted where I want the next from to be built, but I'm starting to get errors and feel the logic might be shaky. Thanks all!
-lT
#!/usr/bin/perl -w
use CGI;
use CGI::Carp qw(fatalsToBrowser);
$upload_dir = "/foo/bar/upload";
$query = new CGI;
$filename = $query->param("somexmlfile");
#pass_word = $query->param("password"); will add later
$filename =~ s/.*[\/\\](.*)/$1/;
$upload_filehandle = $query->upload("somexmlfile");
#cp here, probably will be mv
exec "cp ../foo/bar/existing.xml existing.xml.BAK";
open UPLOADFILE, ">$upload_dir/$filename";
binmode UPLOADFILE;
while(<$upload_filehandle>){
print UPLOADFILE;
}
close UPLOADFILE;
print $query->header ( );
print <<END_HTML
<html>
<h2>File Received</h2>
######################################
#Can I build another HTML/CGI from from here?
######################################
</html>
END_HTML
Update: When I say build another CGI, what I am eventually doing is operations on the uploaded file based on a few simple inputs from the second form. Hope that will clarify things some.
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.