PHP的一个接收问题 php中如何接收通过http传来的一个txt的文件这个我没有头绪,刚接触PHP。像大家请教 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 处理上传文件的教程http://www.php.net/manual/zh/features.file-upload.post-method.php 具体参考PHP手册:特点->文件上传处理http://download.csdn.net/detail/dmtnewtons/4122897#读取excel信息function readCSV($file) { $row = 1; $handle = fopen($file, "r"); $arrTable = array (); while ($data = fgetcsv($handle, filesize($file), ",")) { $arrTab = array (); $num = count($data); $row++; for ($c = 0; $c < $num; $c++) { $arrTab[] = iconv("GBK", "UTF-8", $data[$c]); } array_push($arrTable, $arrTab); } fclose($handle); return $arrTable;}if(!empty($_FILES['datas'])){ #Array ([name] => statusInfors.csv # [type] => application/vnd.ms-excel # [tmp_name] => C:\Windows\Temp\phpF49D.tmp # [error] => 0 # [size] => 163 ) $pathparts = pathinfo($_FILES['datas']['name']); if($pathparts['extension'] != "csv") turnInfor("请导入csv格式文件"); $file = $_FILES['datas']['tmp_name']; $arrcsv = readCSV($file);print_r($arrcsv);}?> <form name="dataList" action="" method="post" enctype="multipart/form-data"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td colspan=2> <input type="button" name="import" value="导入数据" onclick="data.click()" /> <input type="file" id="data" style="visibility:hidden;display:none;" name="datas" value="Import" onchange="importData()" /> </td> </tr></table></form> <script>function importData(){ document.dataList.action = "infors_datas.php"; document.dataList.submit();}</script> 谢谢,大家了,我前面思路不对,所以上网找得资料不对,导致没有做出来。现在我需要有个页面进行文件提交,并在后台处理,然后返回处理结果。感谢dream1206,看了文档后问题解决。 导航栏弹出菜单问题 为什么表单内容出现中文就报错啊 怎么解决啊?????? 怎么样在PHP中取得复选框的内容 关于模板的使用 提取指字字符串问题 请问PHP有连接ACCESS不通过ODBC的方法吗? 问一个参数传递的超菜问题? 文件头问题! 求教一个include_once路径问题 【高分求助】有人遇到过这种情况吗? 表单参数不能获取写入数据库
http://www.php.net/manual/zh/features.file-upload.post-method.php
http://download.csdn.net/detail/dmtnewtons/4122897
#读取excel信息
function readCSV($file) {
$row = 1;
$handle = fopen($file, "r");
$arrTable = array ();
while ($data = fgetcsv($handle, filesize($file), ",")) {
$arrTab = array ();
$num = count($data);
$row++;
for ($c = 0; $c < $num; $c++) {
$arrTab[] = iconv("GBK", "UTF-8", $data[$c]);
}
array_push($arrTable, $arrTab);
}
fclose($handle);
return $arrTable;
}
if(!empty($_FILES['datas'])){
#Array ([name] => statusInfors.csv
# [type] => application/vnd.ms-excel
# [tmp_name] => C:\Windows\Temp\phpF49D.tmp
# [error] => 0
# [size] => 163 )
$pathparts = pathinfo($_FILES['datas']['name']); if($pathparts['extension'] != "csv") turnInfor("请导入csv格式文件");
$file = $_FILES['datas']['tmp_name'];
$arrcsv = readCSV($file);
print_r($arrcsv);
}?>
<form name="dataList" action="" method="post" enctype="multipart/form-data">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan=2>
<input type="button" name="import" value="导入数据" onclick="data.click()" />
<input type="file" id="data" style="visibility:hidden;display:none;" name="datas" value="Import" onchange="importData()" />
</td>
</tr>
</table>
</form>
<script>
function importData(){
document.dataList.action = "infors_datas.php";
document.dataList.submit();
}
</script>
现在我需要有个页面进行文件提交,并在后台处理,然后返回处理结果。
感谢dream1206,看了文档后问题解决。