sending attachment form local drive with mail() – PHP

  php

Q(Question):

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",

A(Answer):

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]

A(Answer):

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]

A(Answer):

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/

A(Answer):

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]

A(Answer):

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]

A(Answer):

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 ")".

LEAVE A COMMENT