Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Sponsored Reviews   High Bandwidth Dedicated Servers   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 05-22-2007, 05:41 AM   #1 (permalink)
Contributing Member
 
funguru's Avatar
 
Join Date: 02-22-04
Location: California
Posts: 989
iTrader: 1 / 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 PR3 $5 Submissions | SpeedHost.in Web Hosting India
funguru is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 05-23-2007, 12:12 AM   #2 (permalink)
v7n Mentor
 
digiweb's Avatar
 
Join Date: 04-07-06
Location: Manchester, NH
Posts: 759
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?
digiweb is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-23-2007, 12:22 AM   #3 (permalink)
Contributing Member
 
funguru's Avatar
 
Join Date: 02-22-04
Location: California
Posts: 989
iTrader: 1 / 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 PR3 $5 Submissions | SpeedHost.in Web Hosting India
funguru is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-23-2007, 09:30 AM   #4 (permalink)
Contributing Member
 
exam's Avatar
 
Join Date: 04-20-06
Posts: 310
iTrader: 0 / 0%
Latest Blog:
None

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.
exam is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-23-2007, 09:48 AM   #5 (permalink)
Contributing Member
 
funguru's Avatar
 
Join Date: 02-22-04
Location: California
Posts: 989
iTrader: 1 / 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 PR3 $5 Submissions | SpeedHost.in Web Hosting India
funguru is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-23-2007, 10:32 AM   #6 (permalink)
Contributing Member
 
exam's Avatar
 
Join Date: 04-20-06
Posts: 310
iTrader: 0 / 0%
Latest Blog:
None

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?
exam is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-23-2007, 10:44 AM   #7 (permalink)
Contributing Member
 
funguru's Avatar
 
Join Date: 02-22-04
Location: California
Posts: 989
iTrader: 1 / 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 PR3 $5 Submissions | SpeedHost.in Web Hosting India
funguru is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-23-2007, 01:45 PM   #8 (permalink)
Contributing Member
 
exam's Avatar
 
Join Date: 04-20-06
Posts: 310
iTrader: 0 / 0%
Latest Blog:
None

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?
exam is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-23-2007, 09:06 PM   #9 (permalink)
Contributing Member
 
funguru's Avatar
 
Join Date: 02-22-04
Location: California
Posts: 989
iTrader: 1 / 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 PR3 $5 Submissions | SpeedHost.in Web Hosting India
funguru is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-23-2007, 11:19 PM   #10 (permalink)
Inactive
 
Join Date: 05-06-07
Posts: 85
iTrader: 0 / 0%
Latest Blog:
None

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.
alainkun is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-24-2007, 04:29 AM   #11 (permalink)
Contributing Member
 
funguru's Avatar
 
Join Date: 02-22-04
Location: California
Posts: 989
iTrader: 1 / 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 PR3 $5 Submissions | SpeedHost.in Web Hosting India
funguru is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-24-2007, 10:46 PM   #12 (permalink)
Inactive
 
Join Date: 05-06-07
Posts: 85
iTrader: 0 / 0%
Latest Blog:
None

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);
alainkun is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-24-2007, 11:12 PM   #13 (permalink)
Contributing Member
 
funguru's Avatar
 
Join Date: 02-22-04
Location: California
Posts: 989
iTrader: 1 / 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 PR3 $5 Submissions | SpeedHost.in Web Hosting India
funguru is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-07-2007, 03:33 AM   #14 (permalink)
Contributing Member
 
funguru's Avatar
 
Join Date: 02-22-04
Location: California
Posts: 989
iTrader: 1 / 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 PR3 $5 Submissions | SpeedHost.in Web Hosting India
funguru is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-07-2007, 04:33 AM   #15 (permalink)
Contributing Member
 
funguru's Avatar
 
Join Date: 02-22-04
Location: California
Posts: 989
iTrader: 1 / 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 PR3 $5 Submissions | SpeedHost.in Web Hosting India
funguru is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > 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

vB 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
Email database brickred Marketing Forum 7 07-13-2004 09:29 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 01:17 AM.
© Copyright 2008 V7 Inc