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, 10: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 10:48 AM. Reason: adding some stuff

Reply With Quote
  #2  
Old November 2nd, 2008, 04: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, 04: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!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

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




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