looking for php email form w/image upload

This is a discussion on "looking for php email form w/image upload" within the PHP Forum section. This forum, and the thread "looking for php email form w/image upload are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Apr 23rd, 2007, 16:07
Junior Member
Join Date: Jul 2005
Location: Lethbridge, Alberta
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Question looking for php email form w/image upload

I currently use email forms for various reasons. I have one customer that would like to have an email form that users would fill out, but would additionally upload an image.

So that when the user hits "submit" it takes all that information and inserts it into an email and sends it off to the owner. The owner receives the text based email with an image attachment.

As I've said I've used email forms and they're great, but this requirement of having the option of attaching an image is a little beyond me. can anyone help me out here? how do I go about attaching an image as an attachment to the email?

Thanks,
josh
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Apr 24th, 2007, 15:34
Reputable Member
Join Date: May 2006
Location: Northampton, UK
Posts: 399
Thanks: 0
Thanked 0 Times in 0 Posts
Re: looking for php email form w/image upload

Ive been thinking about this.

I dont know if theres a way to upload an image and send it as an email attachment.... if anyone does know how to do this let me know.

But....

You could upload the image to your server, then send an html email with the image in the body of the message.

That sounds like the best way to me..... if this is what you decide to do, and your having problems with it, i can write you a quick script that should work with a little modification.

Let me know
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Apr 24th, 2007, 15:44
Junior Member
Join Date: Jun 2006
Location: Wisconsin
Age: 30
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Re: looking for php email form w/image upload

as accurex said, I've always uploaded the file to a temporary directory then sent it the file as an attachment, then i use the unlink() function to delete the file from the server.

Here's the upload function that i use to upload images, you can play around with it and see if you can get it to attach to an email without having to upload it to the server.

Code: Select all
function imageUpload($image, $width, $height, $location) {
    global $_FILES;
    $filename = $_FILES[$image]['name'];
    $temporary_name = $_FILES[$image]['tmp_name'];
    $mimetype = $_FILES[$image]['type'];
    $filesize = $_FILES[$image]['size'];
    $rand = rand(1000, 9999);
    if (is_uploaded_file($_FILES[$image]['tmp_name'])) {
        switch($mimetype) {
            case "image/jpg":
            case "image/jpeg":
            case "image/pjpeg":
                $i = imagecreatefromjpeg($temporary_name);
                break;
            case "image/gif":
                    $i = imagecreatefromgif($temporary_name);
                break;
            case "image/png":
                $i = imagecreatefrompng($temporary_name);
                break;
            }
        //unlink($temporary_name);
        $dest1_x = $width;
        $dest1_y = $height;
        if (imagesx($i) > $dest1_x or imagesy($i) > $dest1_y) {
            if (imagesx($i) >= imagesy($i)) {
                $thumb1_x = $dest1_x;
                $thumb1_y = imagesy($i)*($dest1_x/imagesx($i));
            } else {
                $thumb1_x = imagesx($i)*($dest1_y/imagesy($i));
                $thumb1_y = $dest1_y;
            }
        } else {
            $thumb1_x = imagesx($i);
            $thumb1_y = imagesy($i);
        }
        
        $full = imagecreatetruecolor($thumb1_x,$thumb1_y);
        imagecopyresampled($full, $i ,0, 0, 0, 0, $thumb1_x, $thumb1_y, imagesx($i), imagesy($i));
        $pic = $rand . $filename;
        imagegif($full,$location . $pic,80);
        return $pic;
    }
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
attachment, email attachment, email form, form

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP email form not sending email Kurt PHP Forum 1 Oct 12th, 2007 04:26
Example of Image Upload hanusoft Classic ASP 1 Sep 20th, 2007 10:39
upload image webdeveloper Classic ASP 0 Aug 3rd, 2007 07:54
Form submits to email via php, but email is blank!!?? DH1234 PHP Forum 2 Jun 18th, 2007 10:42
Upload File to Server Via Email Kenny Fix Classic ASP 0 Nov 6th, 2006 17:10


All times are GMT. The time now is 05:05.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42