PHP Installation
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Installation

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old October 29th, 2008, 11:37 AM
lekvarnica69 lekvarnica69 is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Oct 2008
Location: Sweden
Posts: 5 lekvarnica69 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 13 m 51 sec
Reputation Power: 0
PhpMailer attachment problem - phpb8146X instead of picture.jpg

Howdy,

I have a serious problem using the class phpMailer

Everything works finr instead of the attachment filename.
When I select a file for example apple.jpg and then press the submit button in my form, the data is processed with send.php code and send to my address.

It is OK, but if I take a look at my attachement in my email client.
it is called phpb8146X instead of apple.jpg. The attached file called phpb8146X has the same size as the original picture apple.jpg

If i try to rename the file to apple.jpg or just add the .jpg suffix, and bingo! It works like a charm and i can open the picture in every image viewer.

So my question is, why the phpMailer change the name of my attached file?

If someone know how to solve this problem let me know.
I guess it has something to do with this line

this is send.php
require("class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "smtp.something.com"; // lang $mail->CharSet="utf-8"; $mail->From = $from; $mail->FromName = "girllekvarnica"; $mail->AddAddress("girllekv@something.com"); $mail->Subject = "mysubject"; $mail->AddAttachment($myfile); $mail->Encoding = "base64"; $mail->Body = $mybody; $mail->WordWrap = 50; if(!$mail->Send()) { echo 'bad: ' . $mail->ErrorInfo; } else { echo 'OK'; }

this is my form index.html
<HTML> <HEAD> <TITLE>bla mail</TITLE> <meta http-equiv="content-type" content="text/html;charset=utf-8"> </HEAD> <BODY> <HR SIZE=1 NOSHADE> <FORM ACTION="send.php" METHOD="post" ENCTYPE="multipart/form-data"> From: <INPUT TYPE="text" NAME="from" VALUE="" SIZE=50 MAXLENGTH=50><BR> To: <INPUT TYPE="text" NAME="girl" VALUE="" SIZE=50 MAXLENGTH=50><BR><BR> Text:<BR> <TEXTAREA NAME="mybody" COLS="50" ROWS="10"></TEXTAREA><BR> File attach: <INPUT TYPE="file" NAME="myfile"> <BR> <INPUT TYPE="submit" NAME="gogirla" VALUE="gogirl"><BR> </FORM> </BODY> </HTML>

Last edited by lekvarnica69 : October 29th, 2008 at 11:48 AM. Reason: adding some stuff

Reply With Quote
  #2  
Old November 2nd, 2008, 05:28 AM
gwynblade gwynblade is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Oct 2008
Location: Ukraine
Posts: 17 gwynblade User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 33 m 2 sec
Reputation Power: 0
Send a message via AIM to gwynblade
Depending on your configuration php may store file uploads in tmp folder with randomly generated name (like session file names).

AddAttachment can get multiple parameters:

Code:
AddAttachment($path,$name,$encoding,$type);


You can store the original file name then add $name value to show correct file name in the email headers.

Reply With Quote
  #3  
Old November 2nd, 2008, 05:30 AM
gwynblade gwynblade is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Oct 2008
Location: Ukraine
Posts: 17 gwynblade User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 33 m 2 sec
Reputation Power: 0
Send a message via AIM to gwynblade
By the way I think it should have been posted in the coding thread.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Installation > PhpMailer attachment problem - phpb8146X instead of picture.jpg


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek