Jump to content

sizaint

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Everything posted by sizaint

  1. <?php $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/")); session_start(); if( ($_SESSION['security_code']==$_POST['security_code']) && (!empty($_POST['security_code'])) ) { // File upload handling if($_FILES['field_5']['name']!=''){ //$field_5_filename = substr($_FILES['field_5']['name'],strlen($_FILES['field_5']['name'])-4); $field_5_filename = $_FILES['field_5']['name']; //$field_5_filename = "file_5_".date("sihdmY").substr($_FILES['field_5']['name'],strlen($_FILES['field_5']['name'])-4); if(!move_uploaded_file($_FILES['field_5']['tmp_name'], "./files/".$field_5_filename)){ die("File " . $_FILES['field_5']['name'] . " was not uploaded."); } } // //Siz's Tinkering below //Vars $webmasteremail='trevorlay@gmail.com'; $email=$_POST['field_1']; $alias=$_POST['field_2']; $aliascust=$_POST['field_3']; $comments=$_POST['field_4']; $photoname=$_FILES['field_5']['name']; $folder=$where_form_is."files"; //$folder=$where_form_is."files/".$field_5_filename; //".$where_form_is."files/".$field_5_filename." //$filedestination="$folder"; //$filedestination="$folder"."/"."$photoname"."."."$filenameend"; //."/"."$number"."."."$filenameend"; $_SESSION['pic']=""; $filename=$_FILES['field_5']['name']; $filesize=$_FILES['field_5']['size']; $filetmpname=$_FILES['field_5']['tmp_name']; $fileatt_name = "$alias"; // Filename that will be used for the file as the attachment //Bits From old Script $number=0; $numberofresults=0; $handle=opendir ("$folder"); while ($file = readdir ($handle)) { if ($file != "." && $file != "..") { $numberofresults=$numberofresults+1; $texte=explode(".",$file); $znumber=$texte[0]; if ($znumber > $number) { $number=$znumber; } } } closedir($handle); $number=$number+1; $filedestination="$folder"."/"."$filename"; //"."."."$filenameend"; if (move_uploaded_file($filetmpname,$filedestination)) $fileatt = "$filedestination"; // Path to the file if ($filenameend == "gif") { $fileatt_type = "image/gif"; // File Type } else { $fileatt_type = "image/jpeg"; // File Type } $filenamelength=strlen($filename); $filenameend=substr($filename,$filenamelength-3,3); $filenameend=strtolower($filenameend); if ($filenameend != "jpg" and $filenameend != "gif") { die; } // $email_from = "$webmasteremail"; // Who the email is from $email_subject = "Photo for Album From: $alias"; // The Subject of the email $email_txt = "This file was sent by: $alias \n\nE-Mail: $email \n\nCustom Alias: $aliascust \n\nComments: $comments \n\nPhoto Name: $filename \n\nSaved in: $folder"; // Message that the email has in it $email_to = "$webmasteremail"; // Who the email is too $headers = "From: ".$email_from; $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); //$data = fread($file,filesize($fileatt)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message . "$email_txt\n\n"; $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; mail("trevorlay@gmail.com","Photo Upload from: $alias", $email_message, $headers); // //$_POST['field_1'] = "$email"; //$_POST['field_2'] = "$alias"; //END Siz Tinkering // // Checkbox handling $field_6_opts = $_POST['field_6'][0]; /*mail("trevorlay@gmail.com","Photo Upload from: $alias","Form data: Email: " . $_POST['field_1'] . " \nAlias: " . $_POST['field_2'] . " \nAlias with custom chars: " . $_POST['field_3'] . " \nComments: " . $_POST['field_4'] . " \nPhoto: ".$where_form_is."files/".$field_5_filename." (original file name: " . $_FILES['field_5']['name'] . ") \n\nAgree to the terms of use?: $field_6_opts "); */ include("confirm.html"); } else { echo "Invalid Captcha String."; } ?> The error I get are these: Warning: opendir(http://apocalli.com/form/files) [function.opendir]: failed to open dir: not implemented in /home/apocom/public_html/form/processor.php on line 46 Warning: readdir(): supplied argument is not a valid Directory resource in /home/apocom/public_html/form/processor.php on line 48 Warning: closedir(): supplied argument is not a valid Directory resource in /home/apocom/public_html/form/processor.php on line 60 Warning: fread(): supplied argument is not a valid stream resource in /home/apocom/public_html/form/processor.php on line 97 Warning: fclose(): supplied argument is not a valid stream resource in /home/apocom/public_html/form/processor.php on line 99 Its basicly 2 scripts im trying to get the best of both out of, right now it uploads the file to the server fine but lists those errors apon sumbiting the photo, But the e-mail photo Attachment is a blank file.. Any help would be awsome!! (been trying to figure this out for days) Thanks, Siz, PHP newb.
×
×
  • 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.