Пример #1
0
    $i = 0;
    for ($i = 1; $i < $nr; $i++) {
        //file uploaden + naar tabel wegschrijven
        if (trim($_POST["filetext" . $i]) != "") {
            if (!empty($_FILES['file' . $i])) {
                $file = $_POST["carid"] . "_" . strtolower(str_replace(" ", "_", $_FILES['file' . $i]['name']));
                $target_path = getcwd() . "/files/";
                //upload
                $target_path = $target_path . $file;
                chmod($target_path, 0777);
                if (move_uploaded_file($_FILES['file' . $i]['tmp_name'], $target_path)) {
                    $errorfiles .= '<span style="color:green">The file ' . $file . ' has been uploaded.<br />';
                    //Insert blob in table
                    $blobId = $blBlobs->uploadBlobs($target_path . $file);
                    $carfile = new CarFile(0, str_replace("." . findexts($file), "", $file), findexts($file), $_POST["filetext" . $i], $_POST["carid"], $blobId);
                    $blCarFile->insertCarFile($carfile);
                } else {
                    $errorfiles .= "There was an error uploading the file, please try again! (" . $file . ")<br />";
                }
            }
        } else {
            $errorfiles .= "Text is a required field! (" . $_FILES['file' . $i]['name'] . ")<br />";
        }
    }
}
?>
 			

<script language="javascript" type="text/javascript">
    window.top.window.stopUploadFile('<?php 
echo $errorfiles;