Hoe haal ik de verplichting van bijlage uit deze code?

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Johan Vels

Johan Vels

08/07/2014 13:58:24
Quote Anchor link
Hallo allemaal,

Hoe haal ik de verplichting van bijlage uit deze code? (strresume) En dan wel correct, dus dat hij het versturen van de bijlage intact laat als deze wel aanwezig is.

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
    
                    
       $strname
=ucfirst($_REQUEST["strname"]);
    $straddress=ucfirst($_REQUEST["straddress"]);
    $strcity=ucfirst($_REQUEST["strcity"]);
    $strstate=ucfirst($_REQUEST["strstate"]);      
      
       $phone=$_REQUEST["strno"];
       if($phone != ""){ $strno=$phone; } else { $strno="-"; }  
      
    $stremail=$_REQUEST["stremail"];  
    $strcomments=ucfirst($_REQUEST["strcomments"]);

  
    $filename=$_FILES["strresume"]["name"];
    $filetype=$_FILES["strresume"]["type"];
    $filesize=$_FILES["strresume"]["size"];
    $filetemp=$_FILES["strresume"]["tmp_name"];


      
    if($filetype=="application/octet-stream" or $filetype=="text/plain" or $filetype=="application/msword")
    {

  
        $message= '
  
  
            <table cellspacing="0" cellpadding="8" border="0" width="400">
            <tr>
                <td colspan="2"></td>
            </tr>
            <tr bgcolor="#eeeeee">
                <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Name</strong></td>
                <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'
.$strname.'</td>
            </tr>
            <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
            <tr bgcolor="#eeeeee">
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Address</strong></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'
.$straddress.'</td>
              </tr>
            <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
            <tr bgcolor="#eeeeee">
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>City</strong></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'
.$strcity.'</td>
              </tr>
              <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
            <tr bgcolor="#eeeeee">
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>State</strong></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'
.$strstate.'</td>
              </tr>
              <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
            <tr bgcolor="#eeeeee">
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Contact No.</strong></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'
.$strno.'</td>
              </tr>
            <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
            <tr bgcolor="#eeeeee">
                <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Email</strong></td>
                <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'
.$stremail.'</td>
            </tr>
            <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
          
            <tr bgcolor="#eeeeee">
                <td colspan="2" style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Comments</strong></td>
            </tr>              
            <tr bgcolor="#eeeeee">
                <td colspan="2" style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'
.$strcomments.'</td>
            </tr>              
                                  
            <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
         </table>


          

'
;

    // MAIL SUBJECT

    $subject = "Mail with doc file attachment";
  
    // TO MAIL ADDRESS
  
  
    $to="[email protected]";

/*
    // MAIL HEADERS
                      
    $headers  = "MIME-Version: 1.0\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\n";
    $headers .= "From: Name <[email protected]>\n";

*/
 


    // MAIL HEADERS with attachment


    $fp = fopen($strresume, "rb");
    $file = fread($fp, $strresume_size);

    $file = chunk_split(base64_encode($file));
    $num = md5(time());
  
        //Normal headers

    $headers  = "From: Name<[email protected]>\r\n";
       $headers  .= "MIME-Version: 1.0\r\n";
       $headers  .= "Content-Type: multipart/mixed; ";
       $headers  .= "boundary=".$num."\r\n";
       $headers  .= "--$num\r\n";

        // This two steps to help avoid spam  

    $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n";
    $headers .= "X-Mailer: PHP v".phpversion()."\r\n";        

        // With message
      
    $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";
       $headers .= "Content-Transfer-Encoding: 8bit\r\n";
       $headers .= "".$message."\n";
       $headers .= "--".$num."\n";

        // Attachment headers

    $headers  .= "Content-Type:".$strresume_type." ";
       $headers  .= "name=\"".$strresume_name."\"r\n";
       $headers  .= "Content-Transfer-Encoding: base64\r\n";
       $headers  .= "Content-Disposition: attachment; ";
       $headers  .= "filename=\"".$strresume_name."\"\r\n\n";
       $headers  .= "".$file."\r\n";
       $headers  .= "--".$num."--";

  
  
    // SEND MAIL
      
       @mail($to, $subject, $message, $headers);
  

     fclose($fp);

    echo '<font style="font-family:Verdana, Arial; font-size:11px; color:#333333; font-weight:bold">Attachment has been sent Successfully.<br /></font>';
}

else
    {
        echo '<font style="font-family:Verdana, Arial; font-size:11px; color:#F3363F; font-weight:bold">Wrong file format. Mail was not sent.</font>';
        //echo "<script>window.location.href='careers.html';</script>";
    }

?>
 
PHP hulp

PHP hulp

29/04/2024 05:04:57
 
Gerhard l

gerhard l

08/07/2014 15:38:53
Quote Anchor link
Hierin wordt deze verplichting niet gecontroleerd.
 
Johan Vels

Johan Vels

08/07/2014 16:00:14
Quote Anchor link
Jawel, als er geen $file is ingevoerd zal hij melden:

Wrong file format. Mail was not sent.
 
Pipo Clown

Pipo Clown

08/07/2014 16:08:14
Quote Anchor link
Plaats de volgende code op regel 22 :
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
if ((isset($_FILES)) and ($_FILES["strresume"]["tmp_name"] != ''))    {


Plaats op regel 153 een acolade sluiten ( } )
 
Ivo P

Ivo P

08/07/2014 17:47:34
Quote Anchor link
maar dan stuur je dus gelijk ook helemaal geen mail meer.

Ik neem aan dat dat wel de bedoeling van TS is.

Een beetje schuiven met de headers zou dat op kunnen lossen waarna de } een stuk omhoog mag schuiven.
 
Pipo Clown

Pipo Clown

08/07/2014 21:19:15
Quote Anchor link
Wanneer er een bijlage is toegevoegd wordt deze gewoon verstuurd volgens mij.
Ik spring er alleen overheen wanneer er juist geen bijlage geselecteerd is.
 
Obelix Idefix

Obelix Idefix

08/07/2014 21:56:57
Quote Anchor link
@Pipo: de mail wordt toch verstuurd op regel 141.
Als je een afsluitende accolade plaatst op regel 153, ben je volgens mij voorbij het versturen van email.
Zoals Ivo dan constateert, wordt er helemaal geen mail verstuurd?!
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.