[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Uploading files via a HTML Form

Posted on 1998-10-20
1
Medium Priority
?
204 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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

650 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