473,396 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

sending attachment form local drive with mail()



With them help of newsgroups I created a form that makes it possible to sent
an email with an attachement thats on the internet.. How can i attache a
file thats on the users harddrive?

this works great (i upladed the file bijlage.doc)

"FileName"=>"http://www.royvervoort.nl/testatt/bijlage.doc",
i would like to attche the file from my c drive

"FileName"=>"c:\bijlage.doc",
Jul 17 '05 #1
6 3521
In article <40*********************@news.xs4all.nl>,
"Roy G. Vervoort" <ro**********@rojaal.nl> wrote:
With them help of newsgroups I created a form that makes it possible to sent
an email with an attachement thats on the internet.. How can i attache a
file thats on the users harddrive?

this works great (i upladed the file bijlage.doc)

"FileName"=>"http://www.royvervoort.nl/testatt/bijlage.doc",
i would like to attche the file from my c drive

"FileName"=>"c:\bijlage.doc",


PHP can't access the HD of the computer viewing the HTML page. You have
to create a form that has field upload field. As such:

<form action="/insert.php" method="post" enctype="multipart/form-data">
<input type='text' name='subject' />
<input type='file' name='thefile' />
</form>

And in insert.php:
if (file_exists($_FILES["thefile"][tmp_name]){
# Ok, we have a file uploaded.
$filepath = "/temp/path/" . $_FILES["thefile"][name]
move_uploaded_file($_FILES["thefile"][tmp_name], $filepath);
}

Now, when creating the mail(), you can access the $filepath variable
for its location on the harddrive, and you may want to delete that file
after sending the mail.

--
Sandman[.net]
Jul 17 '05 #2
Thanks but i keep getting an error message
Parse error: parse error in /var/www/html/email/insert.php on line 2

and i can not find the problem

can you help me some more
"Sandman" <mr@sandman.net> schreef in bericht
news:mr**********************@news.fu-berlin.de...
In article <40*********************@news.xs4all.nl>,
"Roy G. Vervoort" <ro**********@rojaal.nl> wrote:
With them help of newsgroups I created a form that makes it possible to sent an email with an attachement thats on the internet.. How can i attache a
file thats on the users harddrive?

this works great (i upladed the file bijlage.doc)

"FileName"=>"http://www.royvervoort.nl/testatt/bijlage.doc",
i would like to attche the file from my c drive

"FileName"=>"c:\bijlage.doc",


PHP can't access the HD of the computer viewing the HTML page. You have
to create a form that has field upload field. As such:

<form action="/insert.php" method="post" enctype="multipart/form-data">
<input type='text' name='subject' />
<input type='file' name='thefile' />
</form>

And in insert.php:
if (file_exists($_FILES["thefile"][tmp_name]){
# Ok, we have a file uploaded.
$filepath = "/temp/path/" . $_FILES["thefile"][name]
move_uploaded_file($_FILES["thefile"][tmp_name], $filepath);
}

Now, when creating the mail(), you can access the $filepath variable
for its location on the harddrive, and you may want to delete that file
after sending the mail.

--
Sandman[.net]

Jul 17 '05 #3
I noticed that Message-ID: <40*********************@news.xs4all.nl> from
Roy G. Vervoort contained the following:
$filepath = "/temp/path/" . $_FILES["thefile"][name]


missing ';'

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4
In article <40*********************@news.xs4all.nl>,
"Roy G. Vervoort" <ro**********@rojaal.nl> wrote:
Thanks but i keep getting an error message

Parse error: parse error in /var/www/html/email/insert.php on line 2

and i can not find the problem

can you help me some more


Not unless you show me what code you have on line 2 in your insert.php script.

If you even have a insert.php script - that was supposed to be the script that
handles the mail.

--
Sandman[.net]
Jul 17 '05 #5
I copied your code,

if (file_exists($_FILES["thefile"][tmp_name]){
# Ok, we have a file uploaded.
$filepath = "/temp/path/" . $_FILES["thefile"][name]
move_uploaded_file($_FILES["thefile"][tmp_name], $filepath);
}

Line 2 is:

if (file_exists($_FILES["thefile"][tmp_name]){

(i'm very new to programming in PHP, i used to be an VB programmer several
years ago)

thanks

roy

"Sandman" <mr@sandman.net> schreef in bericht
news:mr**********************@news.fu-berlin.de...
In article <40*********************@news.xs4all.nl>,
"Roy G. Vervoort" <ro**********@rojaal.nl> wrote:
Thanks but i keep getting an error message

Parse error: parse error in /var/www/html/email/insert.php on line 2

and i can not find the problem

can you help me some more
Not unless you show me what code you have on line 2 in your insert.php

script.
If you even have a insert.php script - that was supposed to be the script that handles the mail.

--
Sandman[.net]

Jul 17 '05 #6
In article <40*********************@news.xs4all.nl>,
"Roy G. Vervoort" <ro**********@rojaal.nl> wrote:
I copied your code,

if (file_exists($_FILES["thefile"][tmp_name]){
# Ok, we have a file uploaded.
$filepath = "/temp/path/" . $_FILES["thefile"][name]
move_uploaded_file($_FILES["thefile"][tmp_name], $filepath);
}

Line 2 is:

if (file_exists($_FILES["thefile"][tmp_name]){

(i'm very new to programming in PHP, i used to be an VB programmer several
years ago)


Sorry - that should read

if (file_exists($_FILES["thefile"][tmp_name])){

Note the extra ")".
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: ColinWard | last post by:
Hi. I have the following code in a module which sends email via Outlook. Option Compare Database Option Explicit ' Declare module level variables Dim mOutlookApp As Outlook.Application Dim...
4
by: Liz Patton | last post by:
Here's the exception: System.Exception: Unable to send mail: Could not access 'CDO.Message' object. ---> System.Web.HttpException: Could not access 'CDO.Message' object. --->...
6
by: rekaeps | last post by:
We are developing an ASP.NET 2.0 (C#) application, and I'm having troubles sending e-mail from the server when accessing the web site from a separate client computer. Also, in the same scenario,...
3
by: dnuos | last post by:
We are developing an ASP.NET 2.0 (C#) application, and I'm having troubles sending e-mail from the server when accessing the web site from a separate client computer. Here's some details: ...
8
by: =?Utf-8?B?cm95SGU=?= | last post by:
I have a web service. It creates a email and attached a file sitting one the network drive \\servername\filename. I tried UNC format and also try to mapping drive (eg. g:\text.txt or...
2
by: prasenjit2007 | last post by:
Hello, can u help me sending Email with attachments using the Class phpMailer. On the website I have a link to an html form in which I input the parameters with the names 1)from(textbox name)...
7
by: rn5a | last post by:
When a user posts a HTML Form in an ASP page, the values entered by the user in the Form are mailed to the website owner. Users can also attach a file before posting the Form. To send the...
3
by: raj200809 | last post by:
when i m sending mail i received error from symantec Antivirus" Your email message was unable to be sent because your mail server rejected the message 550-5.7.1 the ip you’re using to send mail is...
1
maliksleo
by: maliksleo | last post by:
hi i am using the following class for email sending but getting this error "Failure sending mail" Imports System.Net.Mail Public Class MailHelper ''' <summary> ''' Sends an mail...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.