arfa has asked for the wisdom of the Perl Monks concerning the following question:
so, first visit, first post so --) here goes:
I am trying to slot an upload routine into an existing database management script so I can include the upload field on the main page (as opposed to a seperated upload page - and script).
So, I am not a coder - just a hacker. BUT, I am a monk - 14 yrs now :))
And, here is my current doodle....
$formdata is the std field defn. for the script I am tweaking
$upload_dir is defined elsewhere
"file" is the upload field name
######____ AK upload from here
######____ AK upload TO here$filename = $formdata{"file"}; $filename =~ s/(\s+|\n)?,(\s+|\n)?/,/g; $upload_filehandle = upload($formdata{"file"}); &upload_file; sub upload_file { $filepath=$filename; if ($filepath =~ /([^\/\\]+)$/) {$filename="$1";} else {$filename="$filepath";} $filename =~ s/\s+//g; open UPLOADFILE, ">$upload_dir/$filename"; while ( <$upload_filehandle> ) {print UPLOADFILE;} close UPLOADFILE; } if ($to_upload == 1) {$formdata{'file'} = $filename}; #ensures just fi +lename written to database
This writes filename to the database - great!
writes filename to $upload_dir - BUT - a zero file; ie. it doesn't move the bits :(
I am hoping for just a simple module but am open to extended suggestions.
with thanks and blessing
> arfa
Edit by tye, remove BR tags, add "/" to closing CODE tag
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: upload mod insert
by Abigail-II (Bishop) on Dec 05, 2003 at 10:09 UTC | |
by Anonymous Monk on Dec 05, 2003 at 10:16 UTC | |
by barrd (Canon) on Dec 05, 2003 at 12:43 UTC | |
by iburrell (Chaplain) on Dec 05, 2003 at 21:46 UTC |