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
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
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
JK
RE: Uploading a file from a local desktop to a Unix server
Mike
michael.j.lacey@ntlworld.com
Cargill's Corporate Web Site
RE: Uploading a file from a local desktop to a Unix server
keep the rudder amid ship and beware the odd typo