There have been a lot of discussions about the file uploading thru the
internet. Currently it is possible to set the form encoding type to
multipart/form-data.
Visit here.
http://www.ao.net/peniel/
This web site has image and file uploading CGI scripts and customized
HTML.
------------------------------
Dr. Young J. Kwon
------------------------------
:There have been a lot of discussions about the file uploading thru the
:Visit here.
:http://www.ao.net/peniel/
I think everyone knows that it can be done. I think people in this
newsgroup want to know how it's done! Do you provide source?
Ivan
Ivan Hendricks
http://www.michianatoday.com/ivanh
NTMailer 1.51
NTPass Beta 1
DTrax Beta 1
Agreed. RFC 1867 deals with the multipart/form-data MIME type.
CGI.pm will help also; it has functions for file upload and other
extensions for Perl.
--
Tim Meals
Electronic Marketing Specialist | "There can be no happiness,
Rebis Industrial Workgroup Software | except within yourself, in
tim....@rebis.com | your art."
http://www.rebis.com | -- Ludwig van Beethoven
the following script prints out to browser the file you u/l however
you could also dump the file to disk, if anyone knows about binary
files, dealing with <cr><lf>, and generally the more advanced stuff,
please post it :)
...........perl script............
#!/usr/local/bin/perl4
# Copyright (c) 1996 Steven E. Brenner
# $Id: fup.cgi,v 1.2 1996/03/30 01:35:32 brenner Exp $
require "./cgi-lib.pl";
# When writing files, several options can be set... here we just set
one
# Limit upload size to avoid using too much memory
$cgi_lib'maxdata = 50000;
# Start off by reading and parsing the data. Save the return value.
# We could also save the file's name and content type, but we don't
# do that in this example.
$ret = &ReadParse;
# A bit of error checking never hurt anyone
&CgiDie("Error in reading and parsing of CGI input") if !defined $ret;
&CgiDie("No data uploaded",
"Please enter it in <a href='fup.html'>fup.html</a>.") if
!$ret;
# Munge the uploaded text so that it doesn't contain HTML elements
# This munging isn't complete -- lots of illegal characters are left
as-is.
# However, it takes care of the most common culprits.
$in{'upfile'} =~ s/</</g;
$in{'upfile'} =~ s/>/>/g;
# Now produce the result: an HTML page...
print &PrintHeader;
print &HtmlTop("File Upload Results");
print <<EOT;
<p>You've uploaded a file. Your notes on the file were:<br>
<blockquote>$in{'note'}</blockquote><br>
<p>The file's contents are:
<pre>
$in{'upfile'}
</pre>
EOT
print &HtmlBot;
.............html form............................
<html>
<head>
<title>Sample File Upload Form</title>
</head>
<body>
<h1>Sample File Upload Form</h1>
<p>This page allows you to upload a file. Note that the script will
limit the size of the file to around 50k (so that the server doesn't
get swamped with data).
<p>The file upload form looks just like any other form except that:
<ol>
<li> the form tag must specify the <tt>POST</tt> method
<li> the form tag must specify an enctype of
<tt>multipart/form-data</tt>
<li> the form must contain an <tt><input type=file></tt>
element.
</ol>
You can do a view source on this document to see all the elements.
<p>The processing of a file upload is exactly like that of ordinary
data; just make a call to <b><tt>ReadParse</b></tt> and the data will
either be put in <tt>%in</tt> or some other variable that you specify.
If you want to write files to disk (rather than store the data in
memory), then you also need to set the variable
<tt>$cgi_lib'writefiles</tt> to indicate the directory where the data
should be written. Other variables allow you to further customize the
file upload.
<hr>
<h2>Please fill in the file-upload form below</h2>
<form method='POST' enctype='multipart/form-data' action='fup.cgi'>
File to upload: <input type=file name=upfile><br>
Notes about the file: <input type=text name=note><br>
<br>
<input type=submit value=Press> to upload the file!
</form>
<hr>
<address>Steven E. Brenner / cgi...@pobox.com</a>
</address>
$Date: 1996/07/31 16:45:47 $
</body>
</html>
.............................................................
ok thats all i have :)
/------------------------|----------------------------\
|Simon Lee | simo...@super.zippo.com|
|Oxford Magnet Technology| simo...@dial.pipex.com|
|Wharf Road |phone +44 1865 880880 ext239|
|Eynsham |fax +44 1865 880872 |
|Oxford | For the worlds best selling |
|United Kingdom | Medical Imaging Magnets! |
\-----------------------------------------------------/