kmhsumit Posted April 9, 2007 Share Posted April 9, 2007 Help Needed! I am new in php. Please tell me what is the “attachment or photo upload” of php code for Email form? I want to added photo upload option for this form. But don’t know the code. I posted total script of mine. Please tell me the attachment or photo upload code of php. or Eidt this script and post to me.. I hope If u can help me! Sumit My CODE: <?php // get posted data into local variables $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $EmailTo = "[email protected]"; $Subject = "OLSA info"; $Name = Trim(stripslashes($_POST['Name'])); $Bday1 = Trim(stripslashes($_POST['Bday1'])); $Bday2 = Trim(stripslashes($_POST['Bday2'])); $Ypass = Trim(stripslashes($_POST['Ypass'])); $Address = Trim(stripslashes($_POST['Address'])); $Telephone = Trim(stripslashes($_POST['Telephone'])); $Mob = Trim(stripslashes($_POST['Mob'])); $Fax = Trim(stripslashes($_POST['Fax'])); $Occ = Trim(stripslashes($_POST['Occ'])); $House = Trim(stripslashes($_POST['R1'])); $Blood = Trim(stripslashes($_POST['Blood'])); // validation $validationOK=true; if (Trim($Ypass)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=fail.html\">"; exit; } // prepare email body text $Body = ""; $Body .= "\n"; $Body .= "\n"; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "\n"; $Body .= "Birthday: "; $Body .= "\n"; $Body .= "\n"; $Body .= $Bday1; $Body .= "\n"; $Body .= "\n"; $Body .= "\n"; $Body .= "\n"; $Body .= $Bday2; $Body .= "\n"; $Body .= "\n"; $Body .= "Year of Passing SSC: "; $Body .= $Ypass; $Body .= "\n"; $Body .= "\n"; $Body .= "Address: "; $Body .= $Address; $Body .= "\n"; $Body .= "\n"; $Body .= "Telephone: "; $Body .= $Telephone; $Body .= "\n"; $Body .= "\n"; $Body .= "Mobile: "; $Body .= $Mob; $Body .= "\n"; $Body .= "\n"; $Body .= "Fax: "; $Body .= $Fax; $Body .= "\n"; $Body .= "\n"; $Body .= "Occupation in Details: "; $Body .= "\n"; $Body .= $Occ; $Body .= "\n"; $Body .= "\n"; $Body .= "House: "; $Body .= $House; $Body .= "\n"; $Body .= "\n"; $Body .= "Blood Group: "; $Body .= $Blood; $Body .= "\n"; $Body .= "\n"; $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=suc.html\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=fail.html\">"; } ?> Link to comment https://forums.phpfreaks.com/topic/46348-need-help-photo-upload-code-for-php/ Share on other sites More sharing options...
SiC_Goat Posted April 9, 2007 Share Posted April 9, 2007 I'm not quite sure how to read your code, it's a tad hard on the eyes. To upload a file and then access it through PHP set the enctype in the form tag to multipart/form-data and have one of your input fields type set to file. This will include the browse button and upload the files binary data. <form action="foobar.php" method="post" enctype="multipart/form-data"> <input type="file" name="myPic"/> <input type="submit" value="upload" /> </form> The file is then uploaded to the temp directory as defined by php's configuration. To access the file in the action script use the superglobal $_FILES[] where the index is the name of the input tag. In this case <? print_r ( $_FILES["myPic"] ); ?> would print out all the information about the uploaded file. Use filesystem functions to then read the file from the server's local filesytem. Link to comment https://forums.phpfreaks.com/topic/46348-need-help-photo-upload-code-for-php/#findComment-225465 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.