/    Sign up×
Community /Pin to ProfileBookmark

adding an upload field to my form

i sthere a way to add an upload section on my form and have it upload to a folder on the site and from there when they submit it it uploads, shows a lil progress bar, and boom when i get the email, it has a link to the picture or embedds it? I alread yknow the coding for the form and having it send via email, its just adding the photos to it which confuses me.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@hastxMar 19.2008 — uploading is the easy part. you might check the sticky post on this forum for uploading images. There are also many other discussions here for adding uploads.

The progress bar requires more code and if that is what you want you might look into some pre-built flash or java uploaders. there is also one here that you can look at.

Once you get the upload working then you can look at placing a link to it in the email.
Copy linkTweet thisAlerts:
@Baby_JaiauthorMar 20.2008 — well based on this code, how would i set the different file extensions allowed

[code=php]<?php
global $DB;
require('conf.php');
$DB = connect();
//Properly prepares data for database
function escape_data ($data) {
if (ini_get('magic_quotes_gpc')){
$data = stripslashes($data);
}
return mysql_escape_string($data);
}
//End Function
If($_GET['m'] == 1){
If(isset($_POST['submit'])){
IF($_POST['Email_Address'] == $_POST['Email_Address_Confirm']){
IF (eregi ("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+.[a-z]{2,4}$", stripslashes(trim($_POST['Email_Address'])))) {
$email = escape_data($_POST['Email_Address']);
} ELSE {
$email = "N/A";
}
}ELSE{
$email .="Emails didn't match, here is the first one they entered: ".escape_data($_POST['Email_Address']);

}
IF(is_uploaded_file($_FILES['Upload_File']['tmp_name'])) {
$zip=$_FILES['Upload_File']['name'];
}ELSE{
$message = "<li>Please choose a picture file to upload and make sure it isn't over 5MB</li>";
$zip= "N/A";
}
IF(isset($_POST['Folder_Name'])){
$folder = escape_data($_POST['Folder_Name']);
}ELSE{
$folder = "N/A";
}
IF (!isset($message)){
IF($zip != "N/A"){
$extension = explode('.', $zip);
$time = time();
$time = substr($time,0,-5);
$filename = $extension[0].'-'.$time.'.'.$extension[1];
IF(!move_uploaded_file($_FILES['Upload_File']['tmp_name'],"whatever/{$filename}")){
$message .="<li>Sorry, your picture file couldn't be uploaded</li>";
}
}
If(isset($filename)){
$filename = "http://www.whatever.com/whatever/".$filename;
}ELSE{
$filename = "NONE PROVIDED";
}

IF (!isset($message)){
$emessage="You have an application from {$email} to upload {$filename} to folder ($folder)";


@mail("[email protected]", "Application for whatever", $emessage, "From: {$email} rn");
$thanks = "<b>Thanks for submiting your picture to BJO! Please be sure to check your email for a response from your application.</b>";
$_POST = array();
}
}
}}
?>[/code]
×

Success!

Help @Baby_Jai spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...