 |
 |
attaching files to forms
|
 |
|
 |
|
Forum Regular
Join Date: Nov 2000
Status:
Offline
|
|
I want to create a form that allows people to attach jpegs that are sent to me when the form is processed. How do you do this? So far, I've created a browse button that looks for the file and attaches it. But when the form is processed, all I receive is the title of the picture, not the file.
Any help would be appreciated. Thanks.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status:
Offline
|
|
I've done this both in PHP and perl, and the methods are very different in both. You will have to be more specific about what language you are using before we can help you.
Oh.. and the PHP documentation is very clear on this sort of thing. It is available online. (RTFM)
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: May 2001
Location: Nottingham, UK
Status:
Offline
|
|
Originally posted by dvwannabe:
<STRONG>I want to create a form that allows people to attach jpegs that are sent to me when the form is processed. How do you do this? So far, I've created a browse button that looks for the file and attaches it. But when the form is processed, all I receive is the title of the picture, not the file.
Any help would be appreciated. Thanks.</STRONG>
what server you running this on?
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Nov 2000
Status:
Offline
|
|
I'm using a Linux server. I've been using PERL for processing my forms. Right now, I have a pretty basic form processing cgi script in place.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: May 2001
Location: Nottingham, UK
Status:
Offline
|
|
Hi there
i'm sure you'll have PHP on there right? If so, this is what i use:
First you need the form, which you already got, but you need to modify the 'form' tag a bit:
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="img1" size="30"></p>
<input type="submit" name="submit" value="Upload File">
</form>
notice the "enctype" but in the form - tells the server there's more than just text coming up.
Now, the upload.php script, really simple:
<?
if ($img1_name != "") {
copy("$img1", "/your/directory/path/$img1_name")
or die("Couldn't copy the file!");
} else {
die("No input file specified");
}
?>
<html>
<head>
<title>Successful File Upload!</title>
<body>
<h1>Success!</h1>
<P>You sent: <? echo "$img1_name"; ?>, a <? echo "$img1_size"; ?>
byte file with a mime type of <? echo "$img1_type"; ?>.</p>
</body>
</html>
that's it. Just make sure you got write permission on both your php temp directory and the directory the file is copying into, otherwise you'll get some nasty errors.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|