Solved

Uploading files via a HTML Form

Posted on 1998-10-20
1
195 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 130 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…

726 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