Solved

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

Posted on 1998-08-27
2
198 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 10 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

623 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