Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    May 2011
    Location
    Iowa
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Upload file and send file via email attachment

    I need an easy to use script that will allow site visitor to upload file and then send file to client via email attachment. It will be placed within a form file that is already written. Any and all help is greatly appreciated. Thank you!

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Search google/sourceforge for PHPMailer, and follow its documentation for implementing it. That should do what you need.

  • #3
    New to the CF scene
    Join Date
    May 2011
    Location
    Iowa
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Search google/sourceforge for PHPMailer, and follow its documentation for implementing it. That should do what you need.
    Thank you, however, that is not what I am needing. I may not have been very good in describing what I need.

    Here is what I have:


    <?php
    //--------------------------Set these paramaters--------------------------

    // Subject of email sent to you.
    $subject = 'Quote Form';

    // Your email address. This is where the form information will be sent.
    $emailadd = 'my@email.com';

    // Where to redirect after form is processed.
    $url = 'http://www.mydomain.com/thankyou.html';

    // Where to direct file upload.
    $file= 'http://www.mydomain.com/upload/';

    // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
    $req = '0';

    // --------------------------Do not edit below this line--------------------------
    $text = "Results from form:\n\n";
    $space = ' ';
    $line = '
    ';
    foreach ($_POST as $key => $value)
    {
    if ($req == '1')
    {
    if ($value == '')
    {echo "$key is empty";die;}
    }
    $j = strlen($key);
    if ($j >= 20)
    {echo "Name of form element $key cannot be longer than 20 characters";die;}
    $j = 20 - $j;
    for ($i = 1; $i <= $j; $i++)
    {$space .= ' ';}
    $value = str_replace('\n', "$line", $value);
    $conc = "{$key}:$space{$value}$line";
    $text .= $conc;
    $space = ' ';
    }
    mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
    echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';{
    }
    if ((($_FILES["file"]["type"] == "application/ai")
    || ($_FILES["file"]["type"] == "application/cdr")
    || ($_FILES["file"]["type"] == "application/dxf")
    || ($_FILES["file"]["type"] == "applicationj/eps")
    || ($_FILES["file"]["type"] == "application/pdf"))
    && ($_FILES["file"]["size"] < 900000))
    {
    if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
    else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

    if (file_exists("upload/" . $_FILES["file"]["name"]))
    {
    echo $_FILES["file"]["name"] . " already exists. ";
    }
    else
    {
    move_uploaded_file($_FILES["file"]["tmp_name"],
    "upload/" . $_FILES["file"]["name"]);
    echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
    }
    }
    }
    else
    {
    echo "Invalid file";
    }
    ?>

    I have changed my email and domain name in the above script for display purposes. What I need to have happen is for the file that is uploaded to also be sent with the email that sends the rest of the information from the form. I hope this helps to better understand what I am asking.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    I'm aware of what you need. PHPMailer is a package designed for easy implementation for things such as html and attachments. Attachments in particular are tricky when using a mail command in PHP.
    You will need to rewrite it to implement it into what you are trying to do. You won't get a handout here, but if you are looking for this to be done for you I'd suggest posting within one of the paid forum requests.

  • #5
    New to the CF scene
    Join Date
    May 2011
    Location
    Iowa
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    I'm aware of what you need. PHPMailer is a package designed for easy implementation for things such as html and attachments. Attachments in particular are tricky when using a mail command in PHP.
    You will need to rewrite it to implement it into what you are trying to do. You won't get a handout here, but if you are looking for this to be done for you I'd suggest posting within one of the paid forum requests.
    Wow, I'm sorry! I wasn't looking for a handout, just a little help. Forgive me for even asking. Guess this forum isn't for helping like others are. BTW, you didn't have to be so rude about it.

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    I don't consider what I've told you to be rude, merely practical. I see a lot of requests that are essentially for handouts.
    You have asked for a script that can handle your attachments, and I have suggested that you use PHPMailer. You simply need to write the interface on top of it which is simply what you already have and replace the mail handling with the PHPMailer classes.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •