Şuanki Dizin: /home/wwwdreamtechnolo/www/spmsolapur.org/mis_software/ |
Şuanki Dosya : /home/wwwdreamtechnolo/www/spmsolapur.org/mis_software/book-excel-upload.php |
<?php require_once('header.php'); require_once('header-left-section.php'); $success_flag=""; $attachement_error=""; ?> <style> .form-control { background-color:#FFF !important; } h1 { text-align:center; color:#101566; font-weight:bold; } .content { margin:10px; } </style> <!-- Content Wrapper. Contains page content --> <div class="content-wrapper" > <!-- Content Header (Page header) --> <section class="content-header"> <div class="container-fluid"> <div class="row mb-2"> <div class="col-sm-12"> <h1>IMPORT BOOK EXCEL DATA</h1> </div> </div> </div><!-- /.container-fluid --> </section> <!-- Main content --> <form method="POST" autocomplete="off" action="<?php echo $_SERVER['PHP_SELF'] ?>" enctype="multipart/form-data" > <div class="form-group col-lg-12" style="min-height:700px;"> <section class="content"> <div class="row"> <div class="col-md-12"> <div class="card card-primary"> <?php if($success_flag==1) { ?> <div class="alert alert-success"> <span class="alert-link">Success! </span>Record added successfully. </div> <?php } ?> <?php if($success_flag==2) { ?> <div class="alert alert-danger"> <span class="alert-link">Failed! </span>This Record Already Exist. </div> <?php } ?> <div class="card-body"> <div class="row"> <div class="form-group col-lg-6"> <label>Select File:</label> <input type="file" class="form-control" name="file" placeholder=" Enter photoimg." required autofocus /> <label class="error_indicator"><?php echo $attachement_error; ?></label> </div> <div class="form-group col-lg-6" style="text-align:center;"> <label>-</label> <br /> <button type="submit" class="btn btn-success" name="save_btn" style="width:30%;">Upload Excel</button> </div> </div> <?php error_reporting(E_ERROR | E_PARSE); include 'Classes/PHPExcel/IOFactory.php'; if(isset($_POST['save_btn'])) { ?> <div style="width:800px; background-color:white; margin:auto;"> <table class="table table-bordered"> <thead class="col_head"> <th class="col_head"width="50">Sr. No</th> <th class="col_head"width="100">ACCess No</th> <th class="col_head" width="200">Status</th> </thead> <tbody> <?php $file_name = $_FILES['file']['name']; // Move file to a temp location $uploadDir = 'upload/'; $img_ext = substr($file_name,-4); $name="_".rand(10000,990000).$img_ext; $uploadFile = $uploadDir.$name; $mimes = array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet','application/vnd.ms-excel','text/plain','text/csv'); if(in_array($_FILES['file']['type'],$mimes)){ // do something if(file_exists($uploadFile)) { echo "4"; } else { if(move_uploaded_file($_FILES['file']['tmp_name'], $uploadFile)) { set_include_path(get_include_path() . PATH_SEPARATOR . 'Classes/'); //$cnt=1; /** PHPExcel_IOFactory */ $objPHPExcel = PHPExcel_IOFactory::load($uploadFile); $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); $linecount = count($sheetData); echo "\t <tr> \n"; for($i = 1; $i <= count($sheetData) ; $i++) { // for($j = 65; $j < (count($sheetData[$i])+65); $j++) { // if(!is_null($sheetData[$i][chr($j)])){ // echo $sheetData[$i][chr($j)]."---".$sheetData[$i][chr($j+1)]."<br>"; // } // } $arr = $sheetData[$i]; $arrVals = array_values($arr); $accession_no = $arrVals[0]; $author = $arrVals[1]; $title = $arrVals[2]; $edition = $arrVals[3]; $place_publisher= $arrVals[4]; $year = $arrVals[5]; $pages = $arrVals[6]; $volume = $arrVals[7]; $book_date = $arrVals[8]; $type = $arrVals[9]; $barcode_no = $arrVals[10]; $subject = $arrVals[11]; $department = $arrVals[12]; if($db->save_books_records_new($accession_no,$author,$title,$edition,$place_publisher,$year,$pages,$volume,$book_date,$type,$barcode_no,$subject,$department)) { echo "<td>".$i."</td><td>".$accession_no."</td><td><span style='color:Green;'>Record added successfully</span></td>"; } else { echo "<td>".$x."</td> <td>".$accession_no."</td><td style='color:Orange'> Failed to Add</td>"; $total_not_updated = $total_not_updated + 1; } echo "\t</tr>\n"; } echo "<script> alert('Uploaded Successfully'); </script>"; } } } ?> </tbody> </table> </div> <?php } ?> </div> </div> </div> </div> </section> </div> </form> <?php require_once('footer.php'); ?>
Linux 65-254-81-4.cprapid.com 5.14.0-284.11.1.el9_2.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 9 05:49:00 EDT 2023 x86_64
Apache
65.254.81.4