renaming uploaded files when file exists
Posted: Thu Feb 08, 2007 3:21 am
hello again
i am nearly done with this neat site of mine
but now i want it to automaticly rename the uploaded files if said file already exists
what i also want to do is that this name is at the same time get this new file name in the database
piece of code:
any idea's or functions that will help me do this?
i am nearly done with this neat site of mine
but now i want it to automaticly rename the uploaded files if said file already exists
what i also want to do is that this name is at the same time get this new file name in the database
piece of code:
Code: Select all
$Datum_upload = date('j-n-Y g:i:s');
$upload_mail = $_POST['upload_mail'];
$download_mail = $_POST['download_mail'];
$Naam = $_POST['Naam_werknemer'];
$beschrijving = $_POST['beschrijving'];
$Filenaam = $_FILES["userfile"]["name"];
$Formaat_bytes = $_FILES['userfile']['size'];
$Formaat = round($Formaat_bytes / 1048576, 2);
$type = $_FILES['userfile']['type'];
//if the $_files variable isn't empty the files are moved
if(!empty($_FILES["userfile"]))
{
// this is the upload dir
$uploaddir = "D:/upload/";
// hier worden de bestanden naar een gegeven locatie verplaatst
if (move_uploaded_file($_FILES["userfile"]["tmp_name"], $uploaddir . $_FILES["userfile"]["name"]))
{
$rs = $objConn->Execute("INSERT INTO Gispen_file_distro (bestandsnaam, naam_gebruiker, email_verzender, email_ontvanger, beschrijving, Grootte_bestand, datum_upload, download)
VALUES('$Filenaam','$Naam','$upload_mail','$download_mail', '$beschrijving','$Formaat','$Datum_upload','onbevestigd')");