Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-22-2007, 05:41 AM
funguru's Avatar
Contributing Member
 
Join Date: 02-22-04
Posts: 999
iTrader: 4 / 100%
funguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nice
attach via database and email in php

i need some help with this.. i have a database stored with pdf files. The user will log in and then he will see a list of pdf files on his screen with a check box next to each, he would have an option to send 1 or multiple pdf files to an email address.

so what he does is ... check marks a pdf and then hits "send", this pop ups a box which will ask for an email address to which the email will be sent.

My problem is that i am not be able to attach the pdf which is checkmarked to the email..

can any one point me to the right direction?

thanks
__________________
Add Link Directory $2 Submissions | SpeedHost.in Web Hosting India
Digg this Post!Add Post to del.icio.us
Reply With Quote
  #2 (permalink)  
Old 05-23-2007, 12:12 AM
digiweb's Avatar
Contributing Member
 
Join Date: 04-07-06
Location: Manchester, NH
Posts: 722
iTrader: 1 / 100%
digiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of light
Send a message via Yahoo to digiweb Send a message via Skype™ to digiweb
attach it to the outgoing email? like this?
Digg this Post!Add Post to del.icio.us
Reply With Quote
  #3 (permalink)  
Old 05-23-2007, 12:22 AM
funguru's Avatar
Contributing Member
 
Join Date: 02-22-04
Posts: 999
iTrader: 4 / 100%
funguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nice
Caroline.. thanks for the help..let me have a look at it and see if this will help.
__________________
Add Link Directory $2 Submissions | SpeedHost.in Web Hosting India
Digg this Post!Add Post to del.icio.us
Reply With Quote
  #4 (permalink)  
Old 05-23-2007, 09:30 AM
exam's Avatar
Senior Member
Latest Blog:
None

 
Join Date: 04-20-06
Posts: 278
iTrader: 0 / 0%
exam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web pro
That looks good Caroline, I've also had success sending mail with this php class.
Digg this Post!Add Post to del.icio.us
Reply With Quote
  #5 (permalink)  
Old 05-23-2007, 09:48 AM
funguru's Avatar
Contributing Member
 
Join Date: 02-22-04
Posts: 999
iTrader: 4 / 100%
funguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nice
i will have a look at that to exam... the problem is that i am getting to attach the file to the email but when it is delivered. the file size is 0KB .. so i dont know whats going wrong with it.
__________________
Add Link Directory $2 Submissions | SpeedHost.in Web Hosting India
Digg this Post!Add Post to del.icio.us
Reply With Quote
  #6 (permalink)  
Old 05-23-2007, 10:32 AM
exam's Avatar
Senior Member
Latest Blog:
None

 
Join Date: 04-20-06
Posts: 278
iTrader: 0 / 0%
exam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web pro
Are the pdfs stored in the database or as files in the filesystem?
Digg this Post!Add Post to del.icio.us
Reply With Quote
  #7 (permalink)  
Old 05-23-2007, 10:44 AM
funguru's Avatar
Contributing Member
 
Join Date: 02-22-04
Posts: 999
iTrader: 4 / 100%
funguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nice
Quote:
Originally Posted by exam View Post
Are the pdfs stored in the database or as files in the filesystem?
stored in a database which are uploaded by admin.
__________________
Add Link Directory $2 Submissions | SpeedHost.in Web Hosting India
Digg this Post!Add Post to del.icio.us
Reply With Quote
  #8 (permalink)  
Old 05-23-2007, 01:45 PM
exam's Avatar
Senior Member
Latest Blog:
None

 
Join Date: 04-20-06
Posts: 278
iTrader: 0 / 0%
exam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web pro
So the pdfs are stored as a binary blob? Or is the filename stored in the database, and the actual pdfs stored in a directory?
Digg this Post!Add Post to del.icio.us
Reply With Quote
  #9 (permalink)  
Old 05-23-2007, 09:06 PM
funguru's Avatar
Contributing Member
 
Join Date: 02-22-04
Posts: 999
iTrader: 4 / 100%
funguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nice
exam.. the file name is stored in the database and the actual pdfs are stored in a folder called upload
__________________
Add Link Directory $2 Submissions | SpeedHost.in Web Hosting India
Digg this Post!Add Post to del.icio.us
Reply With Quote
  #10 (permalink)  
Old 05-23-2007, 11:19 PM
Contributing Member
Latest Blog:
None

 
Join Date: 05-06-07
Posts: 84
iTrader: 0 / 0%
alainkun is a jewel in the roughalainkun is a jewel in the roughalainkun is a jewel in the roughalainkun is a jewel in the roughalainkun is a jewel in the roughalainkun is a jewel in the roughalainkun is a jewel in the rough
Send a message via MSN to alainkun
You have some examples to work with PHP and email in PHP official page:
http://jp.php.net/mail

You can see there examples about attach files.
Digg this Post!Add Post to del.icio.us
Reply With Quote
  #11 (permalink)  
Old 05-24-2007, 04:29 AM
funguru's Avatar
Contributing Member
 
Join Date: 02-22-04
Posts: 999
iTrader: 4 / 100%
funguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nice
Below is the php code i am using to attach...

Code:
<?php $con = mysql_connect("localhost","xxxx","xxxx"); if (!$con) { die('Could not connect.'); } mysql_select_db("inhealth_hospital", $con); $res=mysql_query("select UserID from `patientmaster` where PatientID ='$pid'"); $row = mysql_fetch_array($res); $res1=mysql_query("select File_Name from `patient_status_master` where PatientID ='$pid'"); $row1 = mysql_fetch_array($res1); $fileatt = "./upload/"; // Path to the file $fileatt_type = "application/octet-stream"; // File Type $fileatt_name = $row1['File_Name']; // Filename that will be used for the file as the attachment $email_from = $row['UserID']; // Who the email is from $email_subject = "Sending a report.."; // The Subject of the email $email_txt = "Please see the attached PDF."; // Message that the email has in it $email_to = $_POST['em']; // Who the email is too $headers = "From: ".$email_from; $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message .= $_POST['tm'] . $email_message . "\n\n"; $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; $body = $_POST['tm']; $ok = @mail($email_to, $email_subject, $email_message, $headers); if($ok) { echo "<font face=verdana size=2>The file was successfully sent!</font>"; } else { die("Sorry but the email could not be sent. Please go back and try again!"); } ?>
__________________
Add Link Directory $2 Submissions | SpeedHost.in Web Hosting India
Digg this Post!Add Post to del.icio.us
Reply With Quote
  #12 (permalink)  
Old 05-24-2007, 10:46 PM
Contributing Member
Latest Blog:
None

 
Join Date: 05-06-07
Posts: 84
iTrader: 0 / 0%
alainkun is a jewel in the roughalainkun is a jewel in the roughalainkun is a jewel in the roughalainkun is a jewel in the roughalainkun is a jewel in the roughalainkun is a jewel in the roughalainkun is a jewel in the rough
Send a message via MSN to alainkun
You told us you send the PDF files with 0kb size. Can you really recieve this email? I am, code really send a email?

I think you have to check some important think:
1- Check if you are able to send email WITHOUD add .pdf.
2- Check you .pdf route is really correct.
3- Try code with :
mail($email_to, $email_subject, $email_message, $headers);
instand of:
@mail($email_to, $email_subject, $email_message, $headers);
Digg this Post!Add Post to del.icio.us
Reply With Quote
  #13 (permalink)  
Old 05-24-2007, 11:12 PM
funguru's Avatar
Contributing Member
 
Join Date: 02-22-04
Posts: 999
iTrader: 4 / 100%
funguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nice
alainkun.. i will try it out and let u know. thanks
__________________
Add Link Directory $2 Submissions | SpeedHost.in Web Hosting India
Digg this Post!Add Post to del.icio.us
Reply With Quote
  #14 (permalink)  
Old 06-07-2007, 03:33 AM
funguru's Avatar
Contributing Member
 
Join Date: 02-22-04
Posts: 999
iTrader: 4 / 100%
funguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nice
did not work

Quote:
Originally Posted by alainkun View Post
You told us you send the PDF files with 0kb size. Can you really recieve this email? I am, code really send a email?

I think you have to check some important think:
1- Check if you are able to send email WITHOUD add .pdf.
2- Check you .pdf route is really correct.
3- Try code with :
mail($email_to, $email_subject, $email_message, $headers);
instand of:
@mail($email_to, $email_subject, $email_message, $headers);
__________________
Add Link Directory $2 Submissions | SpeedHost.in Web Hosting India
Digg this Post!Add Post to del.icio.us
Reply With Quote
  #15 (permalink)  
Old 06-07-2007, 04:33 AM
funguru's Avatar
Contributing Member
 
Join Date: 02-22-04
Posts: 999
iTrader: 4 / 100%
funguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nicefunguru is just really nice
i narrowed down the proble to this code

[code
// read the file content into a variable
$data = fread($file,filesize($tmp_name));
[/code]

the code is able to read the file name... but not the file size coz when i get the email, the file name shows as attached in the email but the size is 0kb..

the whole code for the php email script can be found here. http://apptools.com/phptools/forms/forms5.php
__________________
Add Link Directory $2 Submissions | SpeedHost.in Web Hosting India
Digg this Post!Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Email database brickred Marketing Forum 7 07-13-2004 09:29 PM


Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 12:28 PM.
© Copyright 2010 V7 Inc
Powered by vBulletin
Copyright © 2000-2010 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.