How to add a submit scheme on my site..HELP!

emi99

New Member
Hey all! I have been a reader on this forum for a while, but never made a post
before now!

I`m making a page for a friend that works as a photographer!

He wanted to have a function on the homepage, i don`t know how to make:

He want people to be enable to submit their profilepictures thorugh his site. ex:

Your mail:
Uppload your picture
"submitt"

And he will then recieve a mail, with the picture, and a adress where he can send the edited picture back!

If some one helps me with this, i promises that i will love you for ever!
 

smoovo

New Member
You need a form with 2 inputs, email and file. then, you will submit the form to another page (not necessary) and it will be uploaded together with email notifying for the image link and whom it sent from.

I'm hoping you are familiar with PHP, because this one has to be a server side program.

The form
HTML:
<form action="uploader.php" method="post"
enctype="multipart/form-data">
    <label for="email">Email:</label>
    <input type="text" name="email" id="email" />
        <br />
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file" />
        <br />
    <input type="submit" name="submit" value="Submit" />
</form>

The uploader/email sender
PHP:
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 10000000)) // Set the file limit size. (it's been set to 10MB now)
  {
  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"];
      }
    }
	
  //send email
  $email = $_POST['email'] ;
  $subject = "Photo has been submitted" ;
  $message = "The photo has been placed at http://www.myWebsite.com/upload/" . $_FILES["file"]["name"] ; // Need to change the domain name.
  mail( "[email protected]", "Subject: $subject", // Need to change the email.
  $message, "From: $email" );
  
  }
else
  {
  echo "Invalid file";
  }

Make sure to open new folder in the root directory under the name "upload".

- Enjoy.
 
Top