Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4623868
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:02:57+00:00 2026-05-22T03:02:57+00:00

<?php require_once ‘swift-mailer/lib/swift_required.php’; if (isset($_POST[‘submit’])) { //File upload // Where the file is going

  • 0
    <?php

require_once 'swift-mailer/lib/swift_required.php';

if (isset($_POST['submit'])) {

//File upload

// Where the file is going to be placed 
$target_path = "uploads/";

// Add the original filename to our target path.  
//Result is "uploads/filename.extension" 
$target_path = $target_path . basename($_FILES['uploadedfile']['name']);

if (is_uploaded_file($_FILES['uploadedfile']['tmp_name'])) {

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename($_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}   
}
//End of file upload

//Create the Transport
$transport = Swift_MailTransport::newInstance();

//Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);

//Create the message
$message = Swift_Message::newInstance();

  //Give the message a subject
$message->setSubject('New data submitted');

$ip=$_SERVER['REMOTE_ADDR'];
$date=date("l, F j, Y, g:i a");

  //Give it a body
$message->setBody("Here is the information submitted to 
your site 
from $ip on $date.\n\n
--------------------------------\n\n
name: User \n\n
email address: user@hotmail.com \n\n
subject: Test \n\n
comment: Test comment");

  //Add alternative parts with addPart()
//$message->addPart('My amazing body in plain text', 'text/plain');

//Create the attachment
// * Note that you can technically leave the content-type parameter out
$attachment = Swift_Attachment::fromPath($target_path);  

//Attach it to the message
$message->attach($attachment);

//Using setTo() to set all recipients in one go
$message->setTo(array('me@gmail.com' => 'VB'));

//Set a From: address including a name
$message->setFrom(array('me@gmail.com' => 'Contact Us'));

//Send the message
$numSent = $mailer->send($message);

//printf("Sent %d messages\n", $numSent);

if(isset($_FILES['uploadedfile'])){
$pathfile = "/home/me/mysite/uploads/" . $_FILES['uploadedfile']['name'];
@unlink($pathfile);
}

$to = "$email";
$subject = "Thank You!";
$body = "Thank you for e-mailing us.  We will reply as soon as possible.";
// fix for thank you email address
$headers = "From: vlevsha@gmail.com\r\n" .
           "Reply-To: vlevsha@gmail.com\r\n" .
           "X-Mailer: PHP/" . phpversion();
        mail($to, $subject, $body, $headers);






    }



?> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <title>Plain Form</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    </head>
    <body>

<form id="form" action="plain_upload.php" method="post">
    <p>

        <input type="file" name="uploadedfile" />
    </p>

    <p>
        <input type="submit" name="submit" />
    </p>

</form>

    </body>
</html> 

Thank you all in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T03:02:58+00:00Added an answer on May 22, 2026 at 3:02 am

    You need to add an enctype to your form tag

    <form method="post" action="plain_upload.php" enctype="multipart/form-data">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<?php require_once '../plugin/swift/lib/swift_required.php'; // Create the Transport $transport = Swift_SmtpTransport::newInstance('pod51003.outlook.com',587,'tls') ->setUsername('user@connect.polyu.hk') ->setPassword('pw') ; //
Here is my code: <?php require_once 'Swift/lib/swift_required.php'; $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465) ->setUsername('me@ff.com') ->setPassword('pass'); $mailer
My application file: <?php // /src/app.php require_once __DIR__ . '/../lib/vendor/Sensio/silex.phar'; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response;
I have an HTML form POSTing to the following index.php: <?php require_once(/home/full/path/to/included/file.php); ?> And
I have a section of code like the following: ---- file.php ---- require_once(mylib.php); function($a,$b)
from my logout.php : <?php require_once(includes/session.php); ?> <?php require_once(includes/functions.php); ?> <?php if ( isset(
I have an index.php file that has 3 includes <?php require_once('mod.php'); $mod = new
Here's a sample file structure: page.php db.php folder1/subpage.php folder2/fn.php page.php require_once('folder2/fn.php'); folder1/subpage.php require_once('../folder2/fn.php'); folder2/fn.php
I have a file index.php in root directory: <?php require_once ./include/common.php; ?> and file
I am using PHP Swift Mailer to send a bulk mail to a set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.