Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

attachment fo files by end-user on the net through my form

Posted on 1998-08-27
2
Medium Priority
?
200 Views
Last Modified: 2013-12-25
I want to give the facility of file attachment in a form that can be filled up by end-user on my personal page on the net.
Is there a way to send a zip/ascii/binary file to a specified email address. I want to use a form where you can write
    your eamail adress down and get the specified  file format emailed to you.
Can Filemail.pl file help me to solve my problem. which is available at http://gladstone.uoregon.edu/~mwheeler/cgi

In this script I'm not sure about the one variable which is:

      $filebase = '/home/web/draco/www/download';
    # The base path to all files you want sent. If the files are coming from
    # multiple directories you must show this in the filename part of the
    # form such as chat/chat.cgi. If you use the archiving feature all files in
    # this directory (and only this directory) will be listed.

If end-user/client is attaching the file from his hard disk (from C: or A: or D: drive). in that case what will be path for $filebase variable.

One more question:
The html file from where teh end-user will fill up the form. The input tag for giving file attachment facility will be: <input type="file" name="filename">        ?
If not then what?

Waiting for your kind and humble response.

Thanks & Regards
Ritu
0
Comment
Question by:gritu
[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
2 Comments
 
LVL 1

Expert Comment

by:stormerider
ID: 1828331
Something tells me this is worth more than 10 points.. =) I know that uploading a file is done via INPUT TYPE=FILE, but the name is not the filename, it's the name of the variable which will be passed to the CGI script. The contents of that variable, will, I believe, be the file. Something I haven't done yet, but have read about.
0
 
LVL 5

Accepted Solution

by:
thoellri earned 20 total points
ID: 1828332
Yuck - don't even start to muck around with Perl and CGI without using CGI.pm!!!! Go to your next CPAN site and download the latest CGI.pm (version 2.42). Read the installation instructions and install it on your site.
I've just recently implemented the File-Upload option in one of my web-servers and it works like a charm. Here is a small snipplet (sample script that comes with CGI.pm) which shows you how to handle things:

.
# Start a multipart form.
print start_multipart_form(),
    "Enter the file to process:",
    filefield('filename','',45),
    br,
    checkbox_group('count',\@types,\@types),
    p,
    reset,submit('submit','Process File'),
    endform;

# Process the form if there is a file name entered
if ($file = param('filename')) {
    $tmpfile=tmpFileName($file);
    $mimetype = uploadInfo($file)->{'Content-Type'} || '';
    print hr(),
          h2($file),
          h3($tmpfile),
          h4("MIME Type:",em($mimetype));

    my($lines,$words,$characters,@words) = (0,0,0,0);
    while (<$file>) {
        $lines++;
        $words += @words=split(/\s+/);
        $characters += length($_);
    }
    close $file;
.

CGI.pm is nice enough to give you filehandle associated with the file-upload field. You can see that we directly "read()" from the CGI-file-upload-field-parameter. Very nice, robust and easy.

Also consider using available Perl-Modules to do the sending for you. If you send multiple file-types, then consider making them multipart-MIME-messages.

Go to http://www.cpan.org/modules/by-module/CGI  for the CGI.pm module
Go to http://www.perl.com/CPAN-local/modules/by-module/MIME/ for MIME-Lite

Hope this helps
  Tobias

0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

722 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