ok
Direktori : /home/ngwcolle/www/admin/ |
Current File : /home/ngwcolle/www/admin/uploadvideo.php |
<?php include_once('includes/config.php'); if (isset($_FILES["cdate"])) { $eventno = $_POST['pname']; $dept = $_POST['dept']; $edate = $_POST['psa']; $ptype = $_POST['ptype']; $subject = $_POST['subject']; $uploadFolder = "../upload/video/"; $dbfileName = time() . $_FILES["cdate"]["name"]; $fileName = time() . basename($_FILES["cdate"]["name"]); #Get File Name $fileType = pathinfo($_FILES["cdate"]["name"], PATHINFO_EXTENSION); #Get File Extension $fileType = strtolower($fileType); #convert to lowercase $allowTypes = array('jpg', 'png', 'jpeg', 'gif', 'pdf', 'csv', 'mp3', 'mp4'); if (in_array($fileType, $allowTypes)) { #Move file into 'upload' Folder if (move_uploaded_file($_FILES["cdate"]["tmp_name"], $uploadFolder . $fileName)) { $stmt = $mysqli->prepare("insert into tbl_videogallery(orderno,organiser,edate,linkdept,subject,vodeopath) values(?,?,?,?,?,?)"); $stmt->bind_param("ssssss", $eventno, $dept, $edate, $ptype, $subject, $dbfileName); $stmt->execute(); // $query = mysqli_query($con, "insert into tbl_videogallery(orderno,organiser,edate,linkdept,subject,vodeopath) // values('$eventno','$dept','$edate','$ptype','$subject','$dbfileName')"); if ($stmt) { // unlink($uploadFolder.$dbfileName. "." .$fileType); // unlink(realpath($uploadFolder.$dbfileName)); echo "<div class='alert alert-success'><b>$fileName</b> Upload Successfully</div>"; // echo "<div class='alert alert-success'><b>$$uploadFolder.$fileName</b> Upload Successfully</div>"; } else { unlink(realpath($uploadFolder . $dbfileName)); echo "<div class='alert alert-danger'><b>error while insert</b> </div>"; } } else { echo "<div class='alert alert-danger'><b>$fileName</b> Upload Failed. Try Again.</div>"; } } else { echo "<div class='alert alert-danger'>Upload Failed. <b>$fileType</b> Not allowed.</div>"; } }