I am trying to post file and button value and process it in php.
Issue is in my php script ha2e.php
condition if (isset($_FILES['file'])) {}
always goes false
html:
<div id="htmlar2en" style="text-align:center">
<div class="container">
<div style="text-align:center">
<h1> Arabic to English HTML </h1>
<form method="post" enctype="multipart/form-data" target="iframe4" id = "htmla2e">
*.XLSX <input type="file" name="file" /> <input type="submit" id="submit4" name="submit4" value="HTML Arabic to English" />
</form>
<iframe name="iframe4" id="iframe4" src="" style="display:none" ></iframe>
</div>
</div>
</div>
jquery:
$(document).ready(function() {
var extra_data = "This is more stuff to send";
var Bvalue = $(this).attr("value");
$('#submit4').click(function() {
$.ajax({
type: "POST",
url: "he2a.php",
data: {'form': $("#htmla2e").serialize(), 'other': extra_data, 'submit4': Bvalue},
success: function(msg) {
alert("Form Submitted: " + msg);
}
});
});
});
php:
<?php
if (isset($_FILES['file'])) {
header('Content-Type: text/html; charset=UTF-8');
echo '<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />';
require_once "simplexlsx.class.php";
require '../../Arabic.php';
$Arabic = new I18N_Arabic('Transliteration');
$xlsx = new SimpleXLSX( $_FILES['file']['tmp_name'] );
echo "df";
echo '<table border="1" cellpadding="3" style="border-collapse: collapse">';
$eng = array();
list($cols,) = $xlsx->dimension();
foreach( $xlsx->rows() as $k => $r) {
// if ($k == 0) continue; // skip first row
echo '<tr>';
for( $i = 0; $i < $cols; $i++)
{
if ($_POST['submit3'] == 'HTML English to Arabic')
{
$temp = $Arabic->en2ar($r[$i]);
}
else if ($_POST['submit4'] == 'HTML Arabic to Englis')
{
$temp = $Arabic->ar2en($r[$i]);
}
else
continue;
echo '<td>'.( (isset($r[$i])) ? $temp : ' ' ).'</td>';
}
echo '</tr>';
}
echo '</table>';
}
?>