Go Back   Cyber Tech Help Support Forums > Software > Web Development & Graphic Design

Notices

Web Development & Graphic Design Problem Solving for Graphic Design, PHP, ASP, Perl, MySQL, SQL, XML, HTML issues

Reply
 
Topic Tools
  #1  
Old October 15th, 2004, 08:30 PM
mindilator mindilator is offline
New Member
 
Join Date: Oct 2004
Location: Phoenix, AZ
Posts: 5
PHP: upload image and attach to email with PEAR

i'm building a form in php to allow users to upload jpgs, gifs and mpegs only. when they are uploaded i want them attached to an email and sent. i have successfully used PEAR's Mail_mime class to attach form-generated text files to emails, but in this upload form, the form's enctype isn't plain/text.

i can only get it to send a file when the file is a jpg, the enctype is set to multipart/form-data, and when my code line $mime->addAttachment($file, 'image/jpg') or die($php_errormsg); has the mimetype set to image/jpg. i can often get the email to send but this is they only way i've got an actual file to attach to it.

i have $file = $_FILES['latest_submit'], but the mime.php requires me to reference $_FILES['latest_submit']['tmp_name'] to get it to attach. when it does, the file name is called the tmp name and has a .dat extension. having the enctype in the form tag = image/jpg will not attach the file.

when i reference $_FILES['latest_submit']['name'] and echo on the processed page it displays the correct name and the email sends but no file is attached. i want to send the email by referencing $_FILES['latest_submit']['name'] so the proper name is on the file, but it won't attach.

and this only has worked with jpgs. when i try gifs, use image/gif, it won't work. i have very limited luck using application/zip but it only sends jpgs, and they aren't zipped.

how do i send the file (as jpg AND gif or mpeg) with the correct name and correct extension? i'd like to avoid a long messy preg_replace for file names and extensions, and i'm not even sure that would work, but i'll take whatever works.

Last edited by mindilator; October 15th, 2004 at 10:43 PM.
Reply With Quote
  #2  
Old October 19th, 2004, 08:00 PM
mindilator mindilator is offline
New Member
 
Join Date: Oct 2004
Location: Phoenix, AZ
Posts: 5
nevermind, got it working. i'm still having trouble with content-type and different images...
Reply With Quote
  #3  
Old October 19th, 2004, 08:05 PM
degsy's Avatar
degsy degsy is offline
Cyber Tech Help Moderator
 
Join Date: Jul 2001
Location: North-East, UK
Posts: 22,475
Thanks for the update
Reply With Quote
Reply

Bookmarks

Topic 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

Forum Jump

Similar Topics
Topic Topic Starter Forum Replies Last Post
Everythings looking pear shaped, but these smilies are kinda cool! Barfunk Hardware 14 February 9th, 2007 12:24 AM
Unable to attach files in online email and forums BrianP Windows XP 1 January 31st, 2007 12:00 AM
Upload image help! AlexLee Web Development & Graphic Design 1 February 5th, 2005 05:06 PM
Imbedding image in email IDrug Applications 3 January 26th, 2004 09:00 PM
How do I attach bmps bluebear56 Applications 6 October 25th, 2002 03:51 PM


All times are GMT +1. The time now is 05:11 PM.