943,902 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 4241
  • PHP RSS
You are currently viewing page 4 of this multi-page discussion thread; Jump to the first page
Apr 2nd, 2008
0

Re: Serious problem with attchments-please help

Click to Expand / Collapse  Quote originally posted by Vity ...
The full file system is the way the folders are structured in the site ?
It the directory structure of your webspace on the server. Create a file with this, put it in your main directory and open it:

PHP Syntax (Toggle Plain Text)
  1. <?php
  2. echo $_SERVER['DOCUMENT_ROOT'];
  3. ?>

That will give the full file system path to your main directory.


Matti Ressler
Suomedia
Reputation Points: 15
Solved Threads: 19
Junior Poster
Suomedia is offline Offline
154 posts
since Mar 2008
Apr 9th, 2008
0

Re: Serious problem with attchments-please help

Could you please give me a detailed explanation and example about what you said the path must be writeable 777. Beatre i'm kind of lost when you mention that ?
Reputation Points: 10
Solved Threads: 0
Light Poster
Vity is offline Offline
26 posts
since Mar 2008
Apr 9th, 2008
0

Re: Serious problem with attchments-please help

On some web servers you can set permissions using your FTP client. In most you can right click the file or directory and chosse to set permissions. I use Filezilla and it has "file attributes" in the right click menu.

Alternatively, in your web hosting control panel you should have a file manager. Please consult the documentation for your hosting on how to set file and directory permissions.

If you are on a Windows server, I know absolutely nothing


Matti Ressler
Suomedia
Reputation Points: 15
Solved Threads: 19
Junior Poster
Suomedia is offline Offline
154 posts
since Mar 2008
Apr 10th, 2008
0

Re: Serious problem with attchments-please help

Is it possible to change the path of the attachment script to an email address so it is also sent to the same place as the rest of the text ?
Reputation Points: 10
Solved Threads: 0
Light Poster
Vity is offline Offline
26 posts
since Mar 2008
Apr 10th, 2008
0

Re: Serious problem with attchments-please help

The image(s) must be attached to the mail in the way that I showed you. Exactly where on the server the file is moved to is up to you. It actually is normally uploaded to /tmp/ and must be moved from there to a directory within your webspace. This is done with move_uploaded_file() that you see in my script.

If you are attaching mutiple images, you can use a loop rather than repeating the same code multiple times.


Matti Ressler
Suomedia
Reputation Points: 15
Solved Threads: 19
Junior Poster
Suomedia is offline Offline
154 posts
since Mar 2008
Apr 10th, 2008
0

Re: Serious problem with attchments-please help

Okay..... So if i create a folder called upload in the server and in the path put uploader will the attached files be sent to this folder ?
Reputation Points: 10
Solved Threads: 0
Light Poster
Vity is offline Offline
26 posts
since Mar 2008
Apr 10th, 2008
0

Re: Serious problem with attchments-please help

Yes. This should work:

PHP Syntax (Toggle Plain Text)
  1. $path = $_SERVER['DOCUMENT_ROOT'] . '/upload/';


Matti Ressler
Suomedia
Reputation Points: 15
Solved Threads: 19
Junior Poster
Suomedia is offline Offline
154 posts
since Mar 2008
Apr 11th, 2008
0

Re: Serious problem with attchments-please help

hope this wil help u .if not reply me
the path should be something like /home/wc.php

mail_attachment.php

PHP Syntax (Toggle Plain Text)
  1. <?php
  2. function mail_attachment ($from , $to, $subject, $message, $attachment){
  3.  
  4.  
  5. $fileatt = $attachment; // Path to the file
  6. $fileatt_type = "application/octet-stream"; // File Type
  7. $start= strrpos($attachment, '/') == -1 ? strrpos($attachment, '//') : strrpos($attachment, '/')+1;
  8. $fileatt_name = substr($attachment, $start, strlen($attachment)); // Filename that will be used for the file as the attachment
  9.  
  10. $email_from = $from; // Who the email is from
  11. $email_subject = $subject; // The Subject of the email
  12. $email_txt = $message; // Message that the email has in it
  13.  
  14. $email_to = $to; // Who the email is to
  15.  
  16. $headers = "From: ".$email_from;
  17.  
  18. $file = fopen($fileatt,'rb');
  19. $data = fread($file,filesize($fileatt));
  20. fclose($file);
  21. $msg_txt="\n\n";
  22.  
  23. $semi_rand = md5(time());
  24. $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
  25.  
  26. $headers .= "\nMIME-Version: 1.0\n" .
  27. "Content-Type: multipart/mixed;\n" .
  28. " boundary=\"{$mime_boundary}\"";
  29.  
  30. $email_txt .= $msg_txt;
  31.  
  32. $email_message .= "This is a multi-part message in MIME format.\n\n" .
  33. "--{$mime_boundary}\n" .
  34. "Content-Type:text/html; charset=\"iso-8859-1\"\n" .
  35. "Content-Transfer-Encoding: 7bit\n\n" .
  36. $email_txt . "\n\n";
  37.  
  38. $data = chunk_split(base64_encode($data));
  39.  
  40. $email_message .= "--{$mime_boundary}\n" .
  41. "Content-Type: {$fileatt_type};\n" .
  42. " name=\"{$fileatt_name}\"\n" .
  43. //"Content-Disposition: attachment;\n" .
  44. //" filename=\"{$fileatt_name}\"\n" .
  45. "Content-Transfer-Encoding: base64\n\n" .
  46. $data . "\n\n" .
  47. "--{$mime_boundary}--\n";
  48.  
  49.  
  50. $ok = @mail($email_to, $email_subject, $email_message, $headers);
  51.  
  52. if($ok) {
  53. } else {
  54. die("Sorry but the email could not be sent. Please go back and try again!");
  55. }
  56. }
  57. ?>


where u want to add mail code

PHP Syntax (Toggle Plain Text)
  1. <?
  2. session_start();
  3. include "mail_attachment.php";
  4. ?>
  5. $sent1 = mail_attachment("cgbasket@careerglitters.com",$too, $subject1, $body1, $attachment);
Reputation Points: 9
Solved Threads: 4
Junior Poster
queenc is offline Offline
145 posts
since Mar 2008
Apr 12th, 2008
0

Re: Serious problem with attchments-please help

i have attached my php script that i need to attach files to. Could you please place that attachment script you gave me queec?
Attached Files
File Type: php datingavenue.php (4.8 KB, 5 views)
Reputation Points: 10
Solved Threads: 0
Light Poster
Vity is offline Offline
26 posts
since Mar 2008
Apr 12th, 2008
0

Re: Serious problem with attchments-please help

sorry i mean queenc
Reputation Points: 10
Solved Threads: 0
Light Poster
Vity is offline Offline
26 posts
since Mar 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Problem with page navigation
Next Thread in PHP Forum Timeline: Form not sending info...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC