我想得到临时名称excel上传使用php,jquery ajax.My代码如下。但我没有得到任何价值。这个要求是上传excel文件显示在框中。任何身体给这些解决方案问题?吨\
main.php
<div class="form-group">
<label for="exampleInputFile">File Upload</label>
<input type="file" name="file" id="file" size="150">
<p class="help-block">Only Excel/CSV File Import.</p>
</div>
<button type="button" class="btn btn-default"
name="Import" value="Import" onclick="file_up()">
Upload</button>
<div id="upload_show" > </div>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
function file_up()
{
var file=$('#file').val();
$.ajax({
type: "POST",
url: 'first_ajax.php',
data:'file='+file,
success: function(msg)
{
$("#upload_show").html(msg);
}
});
}
</script>
first_ajax.php
< ?php
echo $file1=$_POST['file']['tmp_name'];
?>
$filename= $file1
$file = fopen($filename, "r");
$count = 0;?>
<ul id="my-list">
<?php
while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE)
{
$count++;
if($count>1)
{
?>
<li> <table style="border-color:#3300FF;
border:solid #999999; width:100px; ">
<tr> <td>Name </td> <td> Email</td></tr>
<tr> <td><?php echo $emapData[0]; ?> </td>
<td> <?php echo $emapData[1]; ?></td></tr></table>
</li>
<?php
}
}?>
</ul>
<?php
fclose($file);
?>