Hi there Monks!
I am having a problem with my code where I can not understand why the variable of the file handle is empty.
Here is where its happening:
#!/usr/bin/perl
use strict ;
use warnings ;
use CGI ;
use Net::FTP;
my $cgi = CGI->new();
...
my $file_name = $cgi->param( 'doc' ) || '';
$cgi->upload( 'doc_upload' );
# Can I alter where the file is temporally written here?
my $tmp_file = $cgi->tmpFileName( $file_name );
I'm using this code
warn qq{rename ("$tmp_file", "temp/$file_renamed");\n};
if (!rename("$tmp_file", "temp/$file_renamed" )) {
warn $!, "\n";
}
chmod 0664, "tmp/$file_renamed";
# Error:
#Cannot open Local file doc1.txt: No such file or directory
to print what I am trying to rename to and I found that the "$tmp_file" is empty.
rename ("", doc1.txt");
When it should be printing something like this:
rename ("/tmp/967iaq5eJv", "doc1.txt");
My question is if there is a way to specify were the temp file handle gets written to instead of "/tmp".
At the end of the renaming of the file, I need to FTP this file and or course, it doesn't work because it cant find the file to use in "put".
...
#my $put_file = $ftp->put("$file_renamed") or die "Cannot put file ",
+$ftp->message;
...
Error : Cannot put file The system cannot find the file specified.
I hope I could explain what is happening with the code and thanks a lot for looking at it!!!
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.