sending attachment form local drive with mail()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Roy G. Vervoort

    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"=>"ht tp://www.royvervoort .nl/testatt/bijlage.doc",


    i would like to attche the file from my c drive

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


  • Sandman

    #2
    Re: sending attachment form local drive with mail()

    In article <40332cf0$0$563 $e4fe514c@news. xs4all.nl>,
    "Roy G. Vervoort" <roy.vervoort@r ojaal.nl> wrote:
    [color=blue]
    > 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"=>"ht tp://www.royvervoort .nl/testatt/bijlage.doc",
    >
    >
    > i would like to attche the file from my c drive
    >
    > "FileName"=>"c: \bijlage.doc",[/color]

    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="multip art/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_f ile($_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]

    Comment

    • Roy G. Vervoort

      #3
      Re: sending attachment form local drive with mail()

      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-85370B.10261818 022004@news.fu-berlin.de...[color=blue]
      > In article <40332cf0$0$563 $e4fe514c@news. xs4all.nl>,
      > "Roy G. Vervoort" <roy.vervoort@r ojaal.nl> wrote:
      >[color=green]
      > > With them help of newsgroups I created a form that makes it possible to[/color][/color]
      sent[color=blue][color=green]
      > > 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"=>"ht tp://www.royvervoort .nl/testatt/bijlage.doc",
      > >
      > >
      > > i would like to attche the file from my c drive
      > >
      > > "FileName"=>"c: \bijlage.doc",[/color]
      >
      > 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="multip art/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_f ile($_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][/color]


      Comment

      • Geoff Berrow

        #4
        Re: sending attachment form local drive with mail()

        I noticed that Message-ID: <40339e7c$0$570 $e4fe514c@news. xs4all.nl> from
        Roy G. Vervoort contained the following:
        [color=blue][color=green]
        >> $filepath = "/temp/path/" . $_FILES["thefile"][name][/color][/color]

        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/

        Comment

        • Sandman

          #5
          Re: sending attachment form local drive with mail()

          In article <40339e7c$0$570 $e4fe514c@news. xs4all.nl>,
          "Roy G. Vervoort" <roy.vervoort@r ojaal.nl> wrote:
          [color=blue]
          > 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[/color]

          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]

          Comment

          • Roy G. Vervoort

            #6
            Re: sending attachment form local drive with mail()

            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_f ile($_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-F889AA.09432519 022004@news.fu-berlin.de...[color=blue]
            > In article <40339e7c$0$570 $e4fe514c@news. xs4all.nl>,
            > "Roy G. Vervoort" <roy.vervoort@r ojaal.nl> wrote:
            >[color=green]
            > > 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[/color]
            >
            > Not unless you show me what code you have on line 2 in your insert.php[/color]
            script.[color=blue]
            >
            > If you even have a insert.php script - that was supposed to be the script[/color]
            that[color=blue]
            > handles the mail.
            >
            > --
            > Sandman[.net][/color]


            Comment

            • Sandman

              #7
              Re: sending attachment form local drive with mail()

              In article <403492ac$0$574 $e4fe514c@news. xs4all.nl>,
              "Roy G. Vervoort" <roy.vervoort@r ojaal.nl> wrote:
              [color=blue]
              > 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_f ile($_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)[/color]

              Sorry - that should read

              if (file_exists($_ FILES["thefile"][tmp_name])){

              Note the extra ")".

              Comment

              Working...