Jump to content

Search the Community

Showing results for tags 'attachments'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 3 results

  1. Hi! We have a form that's been used for years, and now we would like to have the added capability of attaching an image. (So a consumer can send us an image that might help with their problem.) Currently, a "confirmation" email is sent to the consumer with all of the info they gave us; a copy of the same information also goes to us. We would like the consumer's image to be saved onto our server, so when we look at the completed form, the "Image:" line has a link to that page. I.e. a consumer attaches an image named "picture.jpg". The copy of the information we get would have a line that reads: "Image: http://www.example.com/test/uploads/picture.jpg". I'm assuming I would use a variable to get the image name to display in order to complete the link. I'm lost about which variable I would use... but that might be because I can't get the image to even save in the folder (I think) it's supposed to. Obviously there's something messed up, but I am lost as to what that is. Any help would be greatly appreciated! The field to attach the image on the form: <label for="upload_file" class="main-label">If you have an image that would help us assist you, please attach it here.</label> <input type="file" name="uploaded_file"> The process file (the attachment part is at the bottom): <?php //Collect contact form data //Check Special Field //Email ASC & Webmaster //Email Sender //Redirect to thank you page require_once($_SERVER['DOCUMENT_ROOT'].'/includes/functions.php'); /******** CONTACT DATA **********/ $name = stripslashes($_POST['name']); $company = stripslashes($_POST['company']); $address = stripslashes($_POST['address']); $city = stripslashes($_POST['city']); $state = stripslashes($_POST['state']); $zipcode = stripslashes($_POST['zipcode']); $country = stripslashes($_POST['country']); $website = $_POST['website']; $phone = stripslashes($_POST['phone']); $fax = stripslashes($_POST['fax']); $email = stripslashes($_POST['contact']); $Referred = stripslashes($_POST['referred']); $CustomerType = stripslashes($_POST['CustomerType']); $Comments = stripslashes($_POST['comments']); $ConsumerHelp = stripslashes($_POST['ConsumerHelp']); $UPC = stripslashes($_POST['UPC']); $Describe = stripslashes($_POST['Describe']); $uploaded_file = ($_FILES['uploaded_file']); /******** CHECK SPECIAL FIELD **********/ $spamcheck = stripslashes($_POST['email']); //if spamcheck isnt blank exit page, no need for error message to user, as its a spam bot if ($spamcheck!=="") { exit; } /******** EMAIL ASC & WEBMASTER **********/ $message = " ----------------------------------------------------------------------------- Information Inquiry ----------------------------------------------------------------------------- $name has visited the web site and would like some information. The details they entered on the website are: Name: $name Company: $company Address: $address City: $city State: $state Zip Code: $zipcode Country: $country Website: $website Phone: $phone Fax: $fax Email: $email Referred to web site: $Referred CustomerType: $CustomerType Comments: $Comments I need help with: $ConsumerHelp UPC code or Item #: $UPC What I am looking for: $Describe Image: $uploaded_file Kind Regards, "; $email_address = "example@example"; $subject = "Information Inquiry"; $headers = "From: $name <$email>"; $message = str_replace("\r",'',$message); //fixes postfix php bug that double spaces messages /******** EMAIL SENDER **********/ $message2 = " ----------------------------------------------------------------------------- Re: Information Inquiry ----------------------------------------------------------------------------- Thank you $name for visiting the web site. We will be using the details you entered to contact you. Name: $name Company: $company Address: $address City: $city State: $state Zip Code: $zipcode Country: $country Website: $website Phone: $phone Fax: $fax Email: $email Referred to web site: $Referred CustomerType: $CustomerType Comments: $Comments I need help with: $ConsumerHelp UPC code or Item #: $UPC What I am looking for: $Describe Kind Regards, "; $email_address2 = "$email"; $subject2 = "Re: Information Inquiry"; $headers2 = "From: <example@example.com>"; $message2 = str_replace("\r",'',$message2); //fixes postfix php bug that double spaces messages //send message 1 and save result in success var (either true for success, or false for fail $success = mail($email_address, $subject, $message, $headers); //conditionally send message2, no need to check success on this one if (strpos($email,'@aol.com') == false) { mail($email_address2, $subject2, $message2, $headers2); } if (!$success) { // What happens when the form does not validate header("Location: sorry.php"); die (); } else { // Your code here to handle a successful verification header("Location: thanks.php"); $success; } ?> <?php $allowedExts = array("gif", "jpeg", "jpg", "png"); $temp = explode(".", $_FILES["uploaded_file"]["name"]); $extension = end($temp); if ((($_FILES["uploaded_file"]["type"] == "image/gif") || ($_FILES["uploaded_file"]["type"] == "image/jpeg") || ($_FILES["uploaded_file"]["type"] == "image/jpg") || ($_FILES["uploaded_file"]["type"] == "image/pjpeg") || ($_FILES["uploaded_file"]["type"] == "image/x-png") || ($_FILES["uploaded_file"]["type"] == "image/png")) && ($_FILES["uploaded_file"]["size"] < 20000) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["uploaded_file"]["error"] . "<br>"; } else { echo "Upload: " . $_FILES["uploaded_file"]["name"] . "<br>"; echo "Type: " . $_FILES["uploaded_file"]["type"] . "<br>"; echo "Size: " . ($_FILES["uploaded_file"]["size"] / 1024) . " kB<br>"; echo "Temp file: " . $_FILES["uploaded_file"]["tmp_name"] . "<br>"; if (file_exists("upload/" . $_FILES["uploaded_file"]["name"])) { echo $_FILES["uploaded_file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["uploaded_file"]["tmp_name"], "upload/" . $_FILES["uploaded_file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?>
  2. Hi - we have been using google code to host our open source projects till now and they get a lot of downloads too.. Google code is going to stop offering downloads starting Jan 2014 and we want an alternate. We have enough bandwidth to host the download our self... but just need some help finding out the right too. the most important thing is that we need to offer direct downloads to our zip files... most of the scripts we find online are really in a manner that the download has to be router through php. is there a script of function out there that can do this job for us?
  3. I am trying to extract csv attachments from emails that have been piped to a php script. The pipe is working, and for the most part the php script is working as well. Unless someone sends the csv file from a source such as an apple iphone. Then the script begins on the wrong line to start the data extraction. Can anyone help me fine tune this to work cleaner?? OR is there simply a better way to extract an attachment from a piped email? Thanks! #!/usr/bin/php -q <?PHP ## sql connection credentials go here. $fd = fopen("php://stdin", "r"); if ($fd) { $t='0'; while (($fde = fgets($fd, 4096)) !== false) { ## Opens the email and saves each line into an array called $email ## $email[$t] = $fde; # $message .= $fde; $t++; } fclose($fd); for ($h='0'; $h<$t; $h++) { ## Splits each line by comma and checks position [0] for specific wording the first line in the csv file. saves line position once found ## $output = explode(",",$email[$h]); if ($output[0] == "item location") { $j = $h+2; # on line $j because that is where I found the item location } } $l='0'; for ($b=$j; $b<$t; $b++) { $pos2 = strrpos($email[$b], "_NextPart_"); if ($pos2 === false) { $pos = strrpos($email[$b], "="); if ($pos === false) { $themail[$l] = $email[$b]; } else { # Addresses a problem of = signs showing up. if I see an = sign combine the next two rows into one row and remove the equals sign. AND add 2 to $b instead of 1 $z=$b+1; $e = array('"', '='); $themail[$l] = "".str_replace($e, '', $email[$b])."".$email[$z].""; $b++; } } else { $b=$t; } $l++; } ## starting point is $j $i=0; for ($k=0; $k<$l; $k++) { ## Splits each line by comma and saves each item from each line to an array ## $output = explode(",",$themail[$k]); foreach ($output as $value) { $foutput[$i] = $value; $i++; } } $r='0'; if ($l > 50) { ## this is done to limit the number of rows being uploaded at one time to 50 max. For some reason, the script starts to get out of sync after 55 rows are processed. 50 seems appropriate anyway ## $l = 50; } for ($e='0'; $e<$l; $e++) { #echo "<br>Set $e <br>"; $r=$e*8; $s='0'; for ($w=$r; $w<$r+8; $w++) { $line[$s] = $foutput[$w]; ## upload the data here ## $s++; } ## sql SELECT statement looks for existing matching data, if it find it then it UPDATEs the line, if not then it INSERTs the line. ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.