View Full Version : Upload function in a form help (php maybe?)
Shemo
July 17th, 2008, 12:35
I'm trying to see if someone is willing to build or point me in the direction of some sort of upload function for a form I've built for my newly created website. I want to allow visitors to upload photos to us, but I know 0 php and 0 javascript.
In the form, I'm hoping that maybe it is able to allow the user to browse for the photo, upload the photo, and attach it in the email that goes along with the rest of the form...if not, at least provide a url to where the photo was uploaded on the server when the email is sent after the form is submitted.
any help is appreciated.
-Shemo
Dynash
July 17th, 2008, 12:43
It's not just a form, you need to have the backend coded too.
Here is one: http://www.webanax.com/download/dc.php?dcid=46977372
Tree
July 17th, 2008, 12:50
Check out these two URLs:
http://us2.php.net/features.file-upload
http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php#attachment
Shemo
July 17th, 2008, 13:12
I already have a php processor a friend built for me a while back when I redid my gaming clan's webpage...I just reuse it for all my forms and edit out the code as needed, so basically from looking on the pages, I'd just insert the upload function code into the form and link it in the php file by it's "name" ?
attached is the php processor I've been using. (note, it's set to process a join request for my gaming clan, so go lite).
<?php
$why_join_ae = $_POST["whyjoinae"];
$clan_requirements = $_POST["requirement"];
$headset_microphone = $_POST["headset"];
$xfire_teamspeak = $_POST["comms"];
$aviable_to_game = $_POST["available"];
$xfire_name = $_POST["xfire"];
$gaming_name = $_POST["gamingname"];
$age = $_POST["age"];
$bday = $_POST["bday"];
$location = $_POST["location"];
$email_address = $_POST["email"];
$internet_type = $_POST["internet"];
$game_playing = $_POST["joinae"];
$invited_to_join = $_POST["whoasked"];
$another_clan = $_POST["clan"];
$what_clan = $_POST["whatclan"];
$why_left = $_POST["anotherclan"];
$computer_specs = $_POST["pc"];
$address_to = "shemo@absoluteeliteclan.com";
$address_from = "From: joinae@absoluteeliteclan.com";
$email_subject_line = $gaming_name . "'s application to join AE";
$email_text = "Why have you decided to join AE? " . $why_join_ae .
"\nHave you read and agreed to the clan requirements? " . $clan_requirements .
"\nDo you have a headset and/or microphone? " . $headset_microphone .
"\nDo you have Xfire and Teamspeak? " . $xfire_teamspeak .
"\nHow often are you able to game? " . $aviable_to_game .
"\nWhat is your Xfire name? " . $xfire_name .
"\nWhat is your gamining name? " . $gaming_name .
"\nHow old are you? " . $age .
"\nWhat is your birthday? " . $bday .
"\nLocation-state & Country? " . $location .
"\nWhat is your email address? " . $email_address .
"\nWhat is your internet connection? " . $internet_type .
"\nWhat game were you playing when asked to join AE? " . $game_playing .
"\nWho asked you to join AE? " . $invited_to_join .
"\nWere you ever part of another clan? " . $another_clan .
"\nIf you answered yes, what clan were you part of? " . $what_clan .
"\nIf you were in another clan, why did you leave? " . $why_left .
"\nWhat are your system specs? (CPU, RAM and Video card) " . $computer_specs;
mail($address_to, $email_subject_line, $email_text, $address_from);
header("Location:http://www.absoluteeliteclan.com/forums");
?>
Dynash
July 17th, 2008, 15:03
You can use the first one i gave you, and add that in according to that. Since that script is just an email script.
Shemo
July 18th, 2008, 00:08
Ok, I've got the upload function installed from the provided link:
http://us2.php.net/features.file-upload
I got the php processor all built and tested it..it works, but it shows the name of the picture and not the actual image.
xhtml code for the form:
<!-- Upload Form -->
<div style="margin-top: 15px; margin-right: auto; margin-bottom: 15px; margin-left: auto; color: #FFFFFF; text-align: center;">
<form enctype="multipart/form-data name="upload_photos" action="upload_photos_complete.php" method="POST">
<p>Name: <br />
<input type="text" name="name" /></p>
<p>State: <br />
<input type="text" name="state" /><p>
<p>Car Make: <br />
<input type="text" name="make" /></p>
<p>Car Model: <br />
<input type="text" name="model" /></p>
<p>How did you hear about us: <br />
<input type="text" name="aboutus" /></p>
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<p>Upload: <br />
<input name="upload" type="file" />
<input type="submit" value="Upload File" /></p>
<input type="submit" value="Submit" />
<input type="reset" value="Reset" />
</form>
</div>
<?php
$name = $_POST["name"];
$state = $_POST["state"];
$car_make = $_POST["make"];
$car_model = $_POST["model"];
$about_us = $_POST["aboutus"];
$upload = $_POST["upload"];
$address_to = "admin@ugly-cars.com ";
$address_from = "From: upload@ugly-cars.com";
$email_subject_line = $name . "'s file upload";
$email_text = "Name:" . $name .
"\nState: " . $state .
"\nCar Make: " . $car_make .
"\nCar Model: " . $car_model .
"\nHow did you hear about us:" . $about_us .
"\nUploaded file: " . $upload;
mail($address_to, $email_subject_line, $email_text, $address_from);
header("Location:http://www.ugly-cars.com/test");
?>
you can check out the form at:
http://www.ugly-cars.com/test/upload.html
is there a way to also make it so hitting upload file next to browse just uploads the photo to the email and not submit the form and the submit button actually submits the entire form?
Powered by vBulletin® Version 4.1.7 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.