Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CGI/Perl script that includes file attachments

Posted on 2001-07-16
3
Medium Priority
?
222 Views
Last Modified: 2013-12-25
Can anyone help with modifications to Matt's Script Archive - formmail.pl so that I can use a "file" (browse) type field to the web form.

OR let me know of another script to do the job.

The "user's" selected file (probably a MSWORD document)would then be sent as an email attachment along with the other data fields contained in the form.

Thanks

Greg
0
Comment
Question by:gfergus
[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
3 Comments
 

Author Comment

by:gfergus
ID: 6291153
Hi Bob

Had some problem with the html/script. The html worked ok but the brower reported 'Internal server error 500' and displayed the path to the perl script in the address bar. There was no email sent and I could not find the 'uploaded' file on the server. I checked the existing formmail.pl script/html and it works with email OK (but does not include a function to upload files).

I have the necessary permission to edit then upload the scripts but I am limited to ftp access. The cgi scripts are contained in a directory called '/cgi' and the html lives in a directory called '/web'. There was no directory called '/tmp' and I was not permmited to create one in '/' but I could create '/web/tmp'. I used 'web/tmp' as the location for the uploaded file.

Maybe I need to find or setup a directory (such as /tmp) that has the correct permissions to allow writing a new file? I found a directory '/files' , maybe I could use '/files' for the upload directory...

I only have ftp access to the UNIX server. However I probably could request a simple change to a system, directory or file permission/security setting.

Please describe the code I can use to debug the perl script. For example, a piece of code that would write out the current variables and display them in a html page, returned to the original html request.

By what process does the user's file get uploaded to the UNIX server? Is it a function of the html form field of type 'file' or is it required that the perl script read in the user's file-path from the form-field type 'file' and then conduct a simple ftp function to upload the file?
Is there a system setting or process block that restricts uploading of a file to the UNIX web server?

Could you write a simple script\html to confirm that the upload function is available?

It seems to me I am asking a lot from you. If you can help I am willing to help you in return with an increase in points awarded or whatever you may suggest, thanks.

Greg

PS. The 'attach_cv_details.pl' script looks just like what I'm after, thanks.

PPS. As of writing this comment all other previous comments are not shown on this page. I hope you get this message ok...
0
 
LVL 8

Accepted Solution

by:
bebonham earned 400 total points
ID: 6302743
"Maybe I need to find or setup a directory (such as /tmp) that has the correct permissions to allow writing
a new file? I found a directory '/files' , maybe I could use '/files' for the upload directory..."


YES, that's one thing

umm,

so, as far as the upload, this is a cgi module upload script
here is the test form:

<HTML>
<HEAD><TITLE>UNTITLED></TITLE></HEAD>
<BODY>
<FORM ENCTYPE="multipart-form/data" ACTION="perlscript.pl" METHOD="POST">
<INPUT TYPE="FILE" NAME="filef">
<INPUT TYPE="SUBMIT">
</FORM>
</BODY>
</HTML>

----------------------perscript.pl

use CGI ':standard';

$temp="yourTEMPDirectory chmoded777";
print header, start_html;
print "I am going to try and upload a file from a form.";
my $fh=param('filef');
$fh=~/.*[\/\\]([^\\\/]+)/;
my $fn=$1;
my $buffer;
open FH, "$tmp/$fn";
while(read($fh,$buffer,1024))
{
print FH $buffer;
}
close FH;



try those out and let me know how it goes

don't forget about the chmod 777 tmpdir!!


Let me know,

Bob
0
 

Author Comment

by:gfergus
ID: 6625791
Thanks for all your help!

Greg
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

609 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