Jump to content

hdbrandon

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

hdbrandon's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm looking for the best way to approach this-my idea isn't formatting nicely. (visit http://qa.theapron.com/index2.php and click either the 2nd or 12th photo....they have test content) Basically, a user uploads a photo. I'm threading a html form with <text area and comments below it. I'm using getimagesize() to get the heightXwidth of the photo, and setting text area cols= 7/8 or 1/2 the width of the photo. But, that doesnt translate well in all instances. So, what's the best was, knowing that the users can upload a variety of photo sizes, to keep the comment thread and form clean? The other idea I had was to resize the photo on upload to a specifc size. If the photo was smaller than that pre-dermined size, someone mat and center it. Are there scripts around that do that?
  2. Ok, so I've tried multiple ways. Either the file gets attached properly but with a filename of ../gallery/X.jpg, which when forwarded to facebook will not get accepted, or the filename is correct but not file attached. <?php include("../framework/config.php"); //get IP address of uploader $ipAddress = getenv("REMOTE_ADDR"); $path_temp = date("Y-m-d_H-i",time()) . "_" . $HTTP_POST_FILES['ufile']['name'][0]; $path1= "../gallery/". $path_temp; //copy file to store copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1); echo "File Name :".$HTTP_POST_FILES['ufile']['name'][0]."<BR/>"; echo "File Size :".$HTTP_POST_FILES['ufile']['size'][0]."<BR/>"; echo "File Type :".$HTTP_POST_FILES['ufile']['type'][0]."<BR/>"; echo "<img src=\"$path1\" width=\"150\" height=\"150\">"; //strip html and slashes, etc $altOne=htmlspecialchars(stripcslashes($_POST[altOne]), ENT_QUOTES); $descOne=htmlspecialchars(stripcslashes($_POST[descOne]), ENT_QUOTES); $bwOne="$_POST[bwOne]"; $facebookOne="$_POST[facebookOne]"; $date = date("Y-m-d_H-i",time()); $store="$_POST[store]"; echo"Alt: $altOne <br> Desc: $descOne <br> Best/Worst: $bwOne <br>Facebook: $facebookOne<br><br><br>"; //display the error or success. $filesize1=$HTTP_POST_FILES['ufile']['size'][0]; if($filesize1 != 0){ echo "We have recieved your files"; if($facebookOne == 'Y'){ function mail_attachment($filename, $mailto, $from_mail, $from_name, $replyto, $subject) { $file = $filename; $file_size = filesize($file); $handle = fopen($file, "r"); $content = fread($handle, $file_size); fclose($handle); $content = chunk_split(base64_encode($content)); $uid = md5(uniqid(time())); $name = basename($file); $header = "From: ".$from_name." <".$from_mail.">\r\n"; $header .= "Reply-To: ".$replyto."\r\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"; $header .= "This is a multi-part message in MIME format.\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-type:text/plain; charset=iso-8859-1\r\n"; $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"; // use different content types here $header .= "Content-Transfer-Encoding: base64\r\n"; $header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n"; $header .= $content."\r\n\r\n"; $header .= "--".$uid."--"; if (mail($mailto, $subject, $message, $header)) { echo "<br/><br/>Mail Sent!"; // or use booleans here } else { echo "<br/><br/>Mail FAILD!"; } } $my_name = "My Name Here"; $my_mail = "facebook@domain.com"; $my_replyto = "facebook@domain.com"; $my_subject = $_POST['descOne']; mail_attachment($path1_temp, "facebook@domain.com", $my_mail, $my_name, $my_replyto, $my_subject); } else{ } } else { echo "ERROR....."; } // What files that have a problem? (if found) if($filesize1==0) { echo "There're something error in your first file"; echo "<BR />"; } ?> Any ideas?
  3. Thanks requinix, but I'm not sure that's the problem. //purely the file name $path_temp = date("Y-m-d_H-i",time()) . "_" . $HTTP_POST_FILES['ufile']['name'][0]; //throw path before it for the photo gallery $path1= "../gallery/". $path_temp; Here is my mail function: function mail_attachment($filename, $mailto, $from_mail, $from_name, $replyto, $subject) { $file = $filename; $file_size = filesize($file); $handle = fopen($file, "r"); $content = fread($handle, $file_size); fclose($handle); $content = chunk_split(base64_encode($content)); $uid = md5(uniqid(time())); $name = basename($file); $header = "From: ".$from_name." <".$from_mail.">\r\n"; $header .= "Reply-To: ".$replyto."\r\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"; $header .= "This is a multi-part message in MIME format.\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-type:text/plain; charset=iso-8859-1\r\n"; $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; //$header .= $message."\r\n\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"; // use different content types here $header .= "Content-Transfer-Encoding: base64\r\n"; $header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n"; $header .= $content."\r\n\r\n"; $header .= "--".$uid."--"; if (mail($mailto, $subject, $message, $header)) { echo "<br/><br/>Mail Sent!"; // or use booleans here } else { echo "<br/><br/>Mail FAILD!"; } } ...calling the function. mail_attachment($path_temp, "facebook@myDomain.com", $my_mail, $my_name, $my_replyto, $my_subject); I'm getting the emails with 0K file attachements...it's just the name of the file, not the file itself.
  4. Hi guys, here's my problem. I have an html upload form that enables a user to upload a photo, which get emailed to a forwarder that i've setup to relay to x@facebook.com, which will get posted to my Facebook wall. However, the same photo will get posted in a gallery, therefore the file upload name includes the server path. Changing this will break the gallery. IE if a user uploads a file named myphoto.jpg $path_temp is ../gallery/myphoto.jpg I need to strip the "../gallery" before it gets attached and sent via. Once forwarded, Facebook doesnt seem to accept photos with the "../" as part of the filename (security I'd imagine). html form ..accepts the photo $path_temp = date("Y-m-d_H-i",time()) . "_" . $HTTP_POST_FILES['ufile']['name'][0]; ....needs to be stripped for facebook to post via their e-mail to wall functionality. $facebookSafe = str_replace("../gallery/", "_", $path_temp); ...mail function mail_attachment($facebookSafe, "facebook@domain.com", $my_mail, $my_name, $my_replyto, $my_subject); The filename is being stripped of the "../," but it's not attaching the file to the email (it's just including the name as a string & no photo). How can I strip the uploaded filename of the charcaters and send via e-mail?
  5. Sorry, I wasnt clear. And, @nightslyr-thanks I took your advice and am using empty. The db has a short description(use for the alt= hover) and longer description for when the picture is expanded(lightbox). Never will both fields be empty. The problem: if their is a short description, use it as the alt=. If their is a longer description, use that when picture is expanded. If one of the two fields are empty, use the other to take its place. So, for instance, picture #27-the last one. The database is: altText: cowboy boot descTest:Have you heard of people of home depot? $date=mysql_result($result,$i,'date'); $altText=mysql_result($result,$i,'alt'); $descText=mysql_result($result,$i,'descText'); //if no photo story, use altText as such. if(empty($descText)){ $descText = $altText; } else if(empty($altText)){ $altText = $descText; } else{ } It seems to be working now. Thanks. I think my cookies were screwing me up too.
  6. I'm pulling text from a database to use as the alt= for a photo gallery. Also, each picture has a longer description. If the description does not exist (ie table field is empty), the alt= text should act as both. Simple enough but its not working? $fname=mysql_result($result,$i,'filename'); $username=mysql_result($result,$i,'userID'); $store=mysql_result($result,$i,'store'); $date=mysql_result($result,$i,'date'); $altText=mysql_result($result,$i,'alt'); $descText=mysql_result($result,$i,'descText'); //if no photo story, use altText as such. if(($descText=='') || ($descText==' ') || ($descText == null)){ $descText == $altText; } echo" <td valign='top'> <a href='$url/gallery/image.php/image.jpg?width=800&height=800&image=$url/gallery/$fname' rel='lightbox[pictures]' title='$descText'> <img src='$url/gallery/image.php/image.jpg?width=75&height=75&image=$url/gallery/$fname' alt='$altText' border='0' /> </a> </td> "; I've tried both ways- $altText==$descText and $descText ==$altText. Shouldnt it be as above? Website is still in production, but see http://qa.theapron.com for an idea of what I mean. This is being used on conjunction with the lightbox script.
  7. Based off of: http://www.finalwebsites.com/forums/topic/php-e-mail-attachment-script The script is not 100% functional. It does send a message, but without an attachment and with random text in the body. function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message) { $file = $path.$filename; $file_size = filesize($file); $handle = fopen($file, 'r'); $content = fread($handle, $file_size); fclose($handle); $content = chunk_split(base64_encode($content)); $uid = md5(uniqid(time())); $name = basename($file); $header = 'From: '.$from_name.' <'.$from_mail.'>\r\n'; $header .= 'Reply-To: '.$replyto.'\r\n'; $header .= 'MIME-Version: 1.0\r\n'; $header .= 'Content-Type: multipart/mixed; boundary=\''.$uid.'\'\r\n\r\n'; $header .= 'This is a multi-part message in MIME format.\r\n'; $header .= '--'.$uid.'\r\n'; $header .= 'Content-type:text/plain; charset=iso-8859-1\r\n'; $header .= 'Content-Transfer-Encoding: 7bit\r\n\r\n'; $header .= $message.'\r\n\r\n'; $header .= '--'.$uid.'\r\n'; $header .= 'Content-Type: application/octet-stream; name=\''.$filename.'\'\r\n'; // use different content types here $header .= 'Content-Transfer-Encoding: base64\r\n'; $header .= 'Content-Disposition: attachment; filename=\''.$filename.'\'\r\n\r\n'; $header .= $content.'\r\n\r\n'; $header .= '--'.$uid.'--'; if (mail($mailto, $subject, '', $header)) { echo 'mail send ... OK'; // or use booleans here } else { echo 'mail send ... ERROR!'; } } $my_file = "test_upload.jpg"; $my_path = $_SERVER['DOCUMENT_ROOT'].'contribute/upload/'; $my_name = 'Name here'; $my_mail = 'facebook@foobar.com'; $my_replyto = 'facebook@foobar.com'; $my_subject = 'foobar.com Facebook Submission.'; $my_message = 'foobar.com Facebook photo submission-attached.'; mail_attachment($my_file, $my_path, 'facebook@foobar.com', $my_mail, $my_name, $my_replyto, $my_subject, $my_message);
  8. Scenario: User uploads pictures via an HTML form, this script will check the filetype & size, and write the submission to a sql table. I have everything working but would like to check the users filename so it doesnt overwrite an exisiting file. If it does, just append a random string to the end of the filename-then write to table. Here's what I've got. Is the best option to redefine $target and add a rand() string to the end of it? What would that look like? <?php include("../framework/config.php"); $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=0; $maxSize=350000; if (($uploaded_size <= $maxSize) && ($uploaded_type=="image/gif") || ($uploaded_type=="image/jpeg") || ($uploaded_type=="image/pjpeg")){ echo "File type & size are ALLOWED.<br>"; $ok=1; if(file_exists($target)){ echo"However, a file with that name already exists. Please rename it and try again.<br/>"; $ok=0; //where i'm working //redeclare $target and add a rand() to the end for unique filename $target = $target . basename( $_FILES['uploaded']['name']) ; } } else{ echo "File type & size are BANNED.<br>"; $ok=0; } if ($ok==0){ Echo "Sorry your file was not uploaded"; } else{ if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)){ echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded."; } else{ } } ?>
  9. Great, thanks. Works like a charm now.
  10. This is what I've got so far. $result=mysql_query($sql); $num=mysql_numrows($result); $i=0; for($rowNum=1; $rowNum<=$num/8;$rowNum++){ echo"<tr>"; for($colNum=1; $colNum<=8;$colNum++){ while ($i < $num){ $fname=mysql_result($result,$i,'filename'); $altText=mysql_result($result,$i,'alt'); echo" <td> <img src='$url/...alt='$altText' /> </td> "; $i++; } echo"</tr>"; } } However, the table row tags are being put at the end of code-and not with 8 column tags within them. Shouldnt this way work as well?
  11. I'm building a photo gallery table of X rows and 8 columns/pictures wide based on the numer of images in the database. Having a brain-freeze though and can't get it to create additional rows. Also, the ending table row tag is nesting properly. Logic problem maybe? Thanks for any help. $sql="SELECT * FROM uploads WHERE (userID LIKE '%$searchString%') OR (alt LIKE '%$searchString%') OR (date LIKE '%$searchString%') OR (store LIKE '%$searchString%');"; $result=mysql_query($sql); $num=mysql_numrows($result); $i=0; $rows=0; while($rows<=$num/8){ echo"<tr>"; while ($i < $num && $pictureCount <= 7) { $fname=mysql_result($result,$i,'filename'); $username=mysql_result($result,$i,'userID'); $store=mysql_result($result,$i,'store'); $date=mysql_result($result,$i,'date'); $altText=mysql_result($result,$i,'alt'); echo" <td> <img src='$url/contribute/upload/image.php?width=75&height=75&cropratio=1:1&image=$url/contribute/upload/$fname' alt='$altText' /> </td> "; $i++; $pictureCount++; } echo"</tr>"; $rows++; }
×
×
  • 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.