×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Uploading a file from a local desktop to a Unix server

Uploading a file from a local desktop to a Unix server

Uploading a file from a local desktop to a Unix server

(OP)
I'm attempting to create a simple script that takes a user defined file from their local desktop and post the file to the remote server.

first off I would need this -

<INPUT type=file size=30 name=file> to open a dialog box and the user can load the file in.

next...What should I do? <form post>???

Can I do a ftp system command to send and mv the file into the right directory?  What would be the simplest?

Thanks

Dano
dskryzer@hotmail.com

What's your major malfunction

RE: Uploading a file from a local desktop to a Unix server

There is a thread in this forum a few days back that deals with some issues on uploading......

Here is a simple example using CGI.pm...


#!/usr/local/bin/perl
# author:  
# date:    june 8,2000
# Purpose: figure out how to use CGI.pm to upload file via
# the browser.
##############################################################
use CGI;
$thisCGI = '/cgi-bin/examples/upload';

$query = new CGI;
print $query->header,$query->start_html(-title=>"UPLOAD THIS");
print $query ->start_multipart_form('POST',"$thisCGI");

print "Enter or Browse to the file you would like to upload.<BR>\n";
print $query->filefield(-name=>'fileID',
-size=>50,
-maxlength=>80);

my $fileID = $query->param('fileID');
@pathName = split(/\\/,$fileID);
$newFile = '/some/new/path/examples/';
$newFile .= pop(@pathName);

if ($fileID)
{
open(OPF,">$newFile") ¦¦ &showError("Failed to open OPF, $!");
while ($bytesread=read($fileID,$buffer,1024)) { print OPF "$buffer"; }
$type = $query->uploadInfo($fileID)->{'Content-Type'};
print "<BR>Upload of $newFile of type $type Successful<BR>\n";
}

print '<BR>',$query->submit('doWhat','uploadMe');
print $query->end_form;
print $query->end_html;

sub showError
{
my @error = @_;
print "<CENTER><font color=\"\#ff4500\">Fatal ERROR - @error</font><BR>\n";
print "Submission aborted - your data was not saved!!<BR>\n";
print "Please use the BACK button to return to the previous page<BR>\n";
print "and correct the error.<BR></CENTER>\n";
print $query->end_form,$query->end_html;
exit;
}


hope this helps.




keep the rudder amid ship and beware the odd typo

RE: Uploading a file from a local desktop to a Unix server

Just out of curiousity how could I use the above script to send the uploaded file as an attachment to an email?

JK

RE: Uploading a file from a local desktop to a Unix server

Ditto - Mike's suggetsion.  The CGI.pm module does not "address" email stuff. ;^)




keep the rudder amid ship and beware the odd typo

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close