[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Script to upload files



Antonio,
  Below is a simple perl script that will upload a file to the server.

1) WARNING!!!! This is VERY insecure as ANYONE could upload ANYTHING to
your server. You will want to wrap this in some type of security. DO NOT
USE THIS AS IS!

2) The file will be written as the user running the Web server so be
sure that the Web server has write access to the $upload_dir


#!/usr/bin/perl -w
use CGI;

# Set up some variables
$upload_dir = "/home/htdocs/";
$query = new CGI;
$query->param('file') =~ m/.*\\(.*)$/;
$dest_file = $1;
$dest_file =~ s/\s//;

$upload_filehandle = $query->upload("file");
open UPLOADFILE, ">$upload_dir/$dest_file";
while ( <$upload_filehandle> )  {    print UPLOADFILE;  }
close UPLOADFILE;

exit(0);


The input form would point to the CGI and have an input field
(type="file") that is named "file"


Pete
-- 
http://www.elbnet.com
ELB Internet Service, Inc.
Web Design, Computer Consulting, Internet Hosting


> Yeah, probably to select a file and then uploading it the way you
> describe. The expected file is going to be 90% of the times a jpg
> image, from a digital camera, so it is really not clear where they
> will be located at. Hopefully, the slected position in the system will
> be remembered next time.
> Thanks Pete.
> 
> --
> To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

-- 
http://www.elbnet.com
ELB Internet Service, Inc.
Web Design, Computer Consulting, Internet Hosting



Reply to: