User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 423,754 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,314 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 2109 | Replies: 48
Reply
Join Date: Mar 2008
Posts: 153
Reputation: Suomedia is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: Serious problem with attchments-please help

  #31  
Apr 2nd, 2008
Originally Posted by Vity View Post
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
  echo $_SERVER['DOCUMENT_ROOT'];
?>

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


Matti Ressler
Suomedia
If you want your dreams to come true, the first thing you must do is to wake up....
Suomedia - Dynamic Content Management
Reply With Quote  
Join Date: Mar 2008
Posts: 26
Reputation: Vity is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Vity Vity is offline Offline
Light Poster

Re: Serious problem with attchments-please help

  #32  
Apr 9th, 2008
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 ?
Reply With Quote  
Join Date: Mar 2008
Posts: 153
Reputation: Suomedia is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: Serious problem with attchments-please help

  #33  
Apr 9th, 2008
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
If you want your dreams to come true, the first thing you must do is to wake up....
Suomedia - Dynamic Content Management
Reply With Quote  
Join Date: Mar 2008
Posts: 26
Reputation: Vity is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Vity Vity is offline Offline
Light Poster

Re: Serious problem with attchments-please help

  #34  
Apr 10th, 2008
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 ?
Reply With Quote  
Join Date: Mar 2008
Posts: 153
Reputation: Suomedia is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: Serious problem with attchments-please help

  #35  
Apr 10th, 2008
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
If you want your dreams to come true, the first thing you must do is to wake up....
Suomedia - Dynamic Content Management
Reply With Quote  
Join Date: Mar 2008
Posts: 26
Reputation: Vity is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Vity Vity is offline Offline
Light Poster

Re: Serious problem with attchments-please help

  #36  
Apr 10th, 2008
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 ?
Reply With Quote  
Join Date: Mar 2008
Posts: 153
Reputation: Suomedia is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: Serious problem with attchments-please help

  #37  
Apr 10th, 2008
Yes. This should work:

$path = $_SERVER['DOCUMENT_ROOT'] . '/upload/';


Matti Ressler
Suomedia
If you want your dreams to come true, the first thing you must do is to wake up....
Suomedia - Dynamic Content Management
Reply With Quote  
Join Date: Mar 2008
Posts: 83
Reputation: queenc is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 3
queenc's Avatar
queenc queenc is offline Offline
Junior Poster in Training

Re: Serious problem with attchments-please help

  #38  
Apr 11th, 2008
hope this wil help u .if not reply me
the path should be something like /home/wc.php

mail_attachment.php

<?php
function mail_attachment ($from , $to, $subject, $message, $attachment){


    $fileatt = $attachment; // Path to the file                  
    $fileatt_type = "application/octet-stream"; // File Type 
    $start=    strrpos($attachment, '/') == -1 ? strrpos($attachment, '//') : strrpos($attachment, '/')+1;
    $fileatt_name = substr($attachment, $start, strlen($attachment)); // Filename that will be used for the file as the     attachment 

    $email_from = $from; // Who the email is from 
    $email_subject =  $subject; // The Subject of the email 
    $email_txt = $message; // Message that the email has in it 
    
    $email_to = $to; // Who the email is to

    $headers = "From: ".$email_from;

    $file = fopen($fileatt,'rb'); 
    $data = fread($file,filesize($fileatt)); 
    fclose($file); 
    $msg_txt="\n\n";

    $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_txt .= $msg_txt;
    
    $email_message .= "This is a multi-part message in MIME format.\n\n" . 
                "--{$mime_boundary}\n" . 
                "Content-Type:text/html; charset=\"iso-8859-1\"\n" . 
               "Content-Transfer-Encoding: 7bit\n\n" . 
    $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"; 


    $ok = @mail($email_to, $email_subject, $email_message, $headers); 

    if($ok) { 
    } else { 
        die("Sorry but the email could not be sent. Please go back and try again!"); 
    } 
}
?>


where u want to add mail code

<?
session_start();
include "mail_attachment.php";
 ?>
$sent1 = mail_attachment("cgbasket@careerglitters.com",$too, $subject1, $body1, $attachment);
Reply With Quote  
Join Date: Mar 2008
Posts: 26
Reputation: Vity is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Vity Vity is offline Offline
Light Poster

Re: Serious problem with attchments-please help

  #39  
Apr 12th, 2008
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, 3 views)
Reply With Quote  
Join Date: Mar 2008
Posts: 26
Reputation: Vity is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Vity Vity is offline Offline
Light Poster

Re: Serious problem with attchments-please help

  #40  
Apr 12th, 2008
sorry i mean queenc
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the PHP Forum

All times are GMT -4. The time now is 1:47 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC