Hey,
I have a script where you can ad a user + a user ID-photo, but the page to update the information + photo is driving me crazy, the info is no problem, but the photo...
This is the script of the update-page, normally it would overwrite the previous uploaded file(as sofie_nr is the number on a identity card (dutch)). But even if I check the $_FILES it says it's empty... I've been freaking on this script the last 5 hours, plz help...

grtz

    <td height="20"><b>Afbeelding ID kaart:</b></td>

  <td>
  <input type="hidden" name="MAX_FILE_SIZE" value="50000">
  <input name="upfile2" type="file" size="40">

</td>
  </tr>
    </table></p>
  <p> 
    <input type="submit" name="Submit" value="Wijzig">
  </p>
</form>
 
<?php

}

}
else {

if(!empty($_POST['upfile2']))
{
$succes= false ;

$uploaddir =  "id_jpeg/";
$filename="".$_POST['sofie_nr'].".jpg";

if ((ereg(".jpg",$filename)) ){

$uploadfile = $uploaddir . $filename;

if (move_uploaded_file($_FILES['upfile2']['tmp_name'], $uploadfile))
	{
	chmod($uploadfile, 0644);
	print("File upload is succesvol afgerond");
	$succes = true ;
	}else{
	print("File upload is mislukt");
	}
}else{
print ("alleen afbeeldingen zijn toegestaan");
}
} else { $succes = "true"; }

if ($succes == true){

$sql= "UPDATE personeel SET 
voorletter = '".$_POST["voorletter"]."',
voornaam = '".$_POST["voornaam"]."',
achternaam = '".$_POST["achternaam"]."',
straat = '".$_POST["straat"]."',
postcode = '".$_POST["postcode"]."',
woonplaats = '".$_POST["woonplaats"]."',
tel = '".$_POST["tel"]."',
tel_zak = '".$_POST["tel_zak"]."',
sofie_nr= '".$_POST["sofie_nr"]."',
functie = '".$_POST["functie"]."',
datum_in = '".$_POST["datum_in"]."'
WHERE pers_id = '".$_POST["id"]."' ";




$result = mysql_query($sql) or die ("FOUT:" . mysql_error());

    Uploaded files do not get referenced through the $POST array. They're in the $FILES array, with the keys being "name", "size", "type", and ...I forgot the other one :o

    But the point is that you need to reference it through the $_FILES array. So,

    
    if ($_FILES['upfile2']['name'] == null)
    {
         // No name for upfile2; no file was uploaded
         // Processing statements for no-uploded file
    }
    else
    {
         // upfile2 had a value for name; file was uploaded
         // Processing statements for uploaded file; possibly move_uploaded_file()
    }
    

    should work for you.

      thx for the reply 🙂 I gave up allready, I'll try it later this day, I'll post if it's succesfull

        Hmm, the $_FILES['upfile2']['name'] returns false, :queasy:

          What's in your <form> tag? Is it prepared to upload a file? I always forget to do this as well...

            	<form name="form1" method="post" action="personeel_wijzig.php">

            What more should be in there? 😕
            thx for the reply 🙂

              Just watch it fly now...I forget that every single time I make an upload script. 😉

                OMFG :eek: 😃 IT WORKED 🙂 thx, oh my god I feel so newbie now 🙂

                  You're welcome...I make the same mistake also every time I make an upload form - in fact, I have yet to see any developer who could constantly remember to do that. We do so much non-upload form work that when we make an upload form, we instinctively type in <form ...> without the enctype.

                  You're not alone on this boat Rackie!

                    Also, mark the thread as resolved using the "Mark Thread Resolved" link under the "Thread Tools" button at the top of the page. 🙂

                      Allright then. Glad it worked out for you!

                        Write a Reply...