File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ if (!empty (isset ($ _POST ["upload " ]))) {
3+ if (($ fp = fopen ($ _FILES ["file-input " ]["tmp_name " ], "r " )) !== FALSE ) {
4+ ?>
5+ <table class="tutorial-table" width="100%" border="1" cellspacing="0">
6+ <?php
7+ $ i = 0 ;
8+ while (($ row = fgetcsv ($ fp )) !== false ) {
9+ $ class ="" ;
10+ if ($ i ==0 ) {
11+ $ class = "header " ;
12+ }
13+ ?>
14+ <tr>
15+ <td class="<?php echo $ class ; ?> "><?php echo $ row [0 ]; ?> </td>
16+ <td class="<?php echo $ class ; ?> "><?php echo $ row [1 ]; ?> </td>
17+ <td class="<?php echo $ class ; ?> "><?php echo $ row [2 ]; ?> </td>
18+ </tr>
19+ <?php
20+ $ i ++;
21+ }
22+ fclose ($ fp );
23+ ?>
24+ </table>
25+ <?php
26+ $ response = array ("type " => "success " , "message " => "CSV is converted to HTML successfully " );
27+ } else {
28+ $ response = array ("type " => "error " , "message " => "Unable to process CSV " );
29+ }
30+ }
31+ ?>
32+ </div>
33+ <?php if (!empty ($ response )) { ?>
34+ <div class="response <?php echo $ response ["type " ]; ?>
35+ ">
36+ <?php echo $ response ["message " ]; ?>
37+ </div>
38+ <?php } ?>
You can’t perform that action at this time.
0 commit comments