[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Uploading files via a HTML Form

Posted on 1998-10-20
1
Medium Priority
?
206 Views
Last Modified: 2010-03-05
How do I create a perl script that will allow somebody to attatch a file to a HTML form.

The file, along with other text inputs, will always be stored in the same directory with the same file name.

I am familar with perl, cgi scripting, file creation etc.
All I need is a pointer on how this can be done.

i would imagine that somehow a data stream is opened, and I could then take this (binary?) data and save it to a file?

how does the HTML form send the data?

thanks.
0
Comment
Question by:blacksheep
1 Comment
 
LVL 28

Accepted Solution

by:
sybe earned 520 total points
ID: 1205537
Make a form like this:

============
<FORM ACTION="/cgi-bin/upload.pl" ENCTYPE="MULTIPART/FORM-DATA" METHOD="POST">
<INPUT TYPE="FILE" NAME="FILE1">
</FORM>
===========

code for upload.pl

===========

require "./cgi-lib.pl";

$cgi_lib'maxdata = 50000;

$ret = &ReadParse;

open(OUTFILE, ">upload/test.gif");
binmode (OUTFILE);
syswrite (OUTFILE, $in{'upfile'}, length $in{'upfile'});
close(OUTFILE);


print &PrintHeader;

print "\n<P>File was uploaded<P>";

print &HtmlBot;

===============
It uses cgi-lib.pl, which you can get from http://www.bio.cam.ac.uk/cgi-lib/



0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question