Toon posts:

[PHP]

Pagina: 1
Acties:
  • 44 views sinds 30-01-2008

Verwijderd

Topicstarter
eerst maar mijn code:

code:
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
              <form method="GET" action='index.php' enctype='multipart/form-data'>
<?php              
        $test = $_GET['test'];
        ini_set ('display_errors',1);
        error_reporting(E_ALL&-E_NOTICE);
        
        if ($test == "")
        {

?>
           <p>&nbsp;</p>

                <input type="hidden" name="functie" value="upload" />
                            
                <table width="100%"  border="0">
                  <tr>
                    <td width="22%">Naam: * </td>
                    <td width="78%"><input name="naam" type="text" size="40" maxlength="40" class="zkveld"></td>
                  </tr>
                  <tr>
                    <td>Adres:</td>
                    <td><input name="adres" type="text" size="40" maxlength="100"class="zkveld"></td>
                  </tr>
                  <tr>
                    <td>Woonplaats:</td>
                    <td><input name="woonplaats" type="text" size="40" maxlength="50"class="zkveld"></td>
                  </tr>
                  <tr>
                    <td>Telefoon:</td>
                    <td><input name="telefoon" type="text" size="40" maxlength="20"class="zkveld"></td>
                  </tr>
                  <tr>
                    <td>Contactpersoon:</td>
                    <td><input name="contactpersoon" type="text" size="40" maxlength="40"class="zkveld"></td>
                  </tr>
                  <tr>
                    <td>E-mail: * </td>
                    <td><input name="email" type="text" size="40" maxlength="30" class="zkveld"></td>
                  </tr>
                  <tr>
                  <td colspan="2">  <br> Voor een juiste prijsindicatie, stuurt u dan een foto mee van stoel, bank etc.

                    </td>
                  </tr>
                 <tr>
                    <td>Bestand invoegen </td>
                    <td><input name="bestand" type="file" class="zkveld_groot" id="bestand" value="bestand" >
                    
                </td>
                  </tr>
                  <tr>
                    <td align="left" valign="top">Commentaar: * </td>
                    <td><textarea name="commentaar" cols="40" rows="10"class="zkveld_groot"></textarea></td>
                  </tr>
                </table>
                
                <p>* = verplicht veld </p>
                <p class="knoppen">
                  <input name="test" type="submit"  value="verzenden" class="butt  id="verstuur""><!--<span style="text-decoration:underline;">V</span>erzenden</button>-->
                  <input name="reset" type="reset" class="butt" id="reset" value="reset">
                  
                </p>
              </form> 
                <p>Voor op of aanmerkingen op de site, e-mail naar de <a href="mailto:webmaster@meubelstoffering-boone.nl" class="Links">webmaster</a></p>
<?php
    }
    
    if ($test == "verzenden")
        {
            $_FILES = $_GET['file'];
            
            if (is_uploaded_file($_FILES['bestand']['tmp_name'])) {
                $size = filesize($_FILES['bestand']['tmp_name']);
                $f = fopen($_FILES['bestand']['tmp_name'], 'r');
                $content = chunk_split(base64_encode(fread($f, $size)));
                fclose($f);
    
                $header = 'Content-Type: multipart/mixed; boundary="This__Is__The__Boundary"
                MIME-Version: 1.0
                From: Contactpagina@meubelstoffering-boone.nl';
                
                    mail ("naam@naam.nl","Aanvraag via website",
                "--This__Is__The__Boundary
                Content-Transfer-Encoding: binary
                Content-Type: text/plain
                
                naam klant :  $naam 
                adres =  $adres 
                woonplaats = $woonplaats 
                telefoon = $telefoon 
                contactpersoon = $contactpersoon 
                e-mail = $email
                
                commentaar = $commentaar
                
                --This__Is__The__Boundary
                Content-Type: application/octet-stream; name=\"".basename($_FILES['bestand']['name'])."\"
                Content-Transfer-Encoding: base64
                Content-Length: ".strlen($content)."
                
                ".$content."
                --This__Is__The__Boundary--
                .
                ",
                    $header);
                    print "uw aanvraag is verzonden";
                }
        }
    
?>



mijn probleem is dat waneer ik het op deze manier doet dan krijg ik een foutmelding Undefined index
het zit hem in het getten van het bestand

dit stukje :

code:
1
2
3
4
5
6
7
8
9
if ($test == "verzenden")
        {
            $_FILES = $_GET['file'];
            
            if (is_uploaded_file($_FILES['bestand']['tmp_name'])) {
                $size = filesize($_FILES['bestand']['tmp_name']);
                $f = fopen($_FILES['bestand']['tmp_name'], 'r');
                $content = chunk_split(base64_encode(fread($f, $size)));
                fclose($f);


Ik hoop dat iemand weet hoe het wel moet??? :(

  • AtleX
  • Registratie: Maart 2003
  • Niet online

AtleX

Tyrannosaurus Lex 🦖

Geuploade files zitten niet in je $_GET superglobal, maar al automagisch in $_FILES.

Deze regel:
PHP:
1
$_FILES = $_GET['file'];

is dus niet nodig.

Sole survivor of the Chicxulub asteroid impact.


  • Bosmonster
  • Registratie: Juni 2001
  • Laatst online: 10-04 15:11

Bosmonster

*zucht*

PHP:
1
$_FILES = $_GET['file'];


:? sla de manual er nog eens op na zou ik zeggen... of een willekeurige upload tutorial

  • whoami
  • Registratie: December 2000
  • Laatst online: 14-04 20:38
Allereerst: het is niet de bedoeling om hier duizend regels code te posten, met dan een error-melding.
Wat debugwerk, wat leeswerk in de manual, zou voldoende moeten zijn

https://fgheysels.github.io/


Dit topic is gesloten.