我想在前台页面中嵌入一个上传CSV文件的按钮,然后实现用户用CSV导入数据
前台是- <input type="file" name="mycsv" /><input type="submit" name="addcsv" value="导入" class="submit" />
复制代码 后台数据处理是- .......
- } elseif (submitcheck('addcsv')) {
- //添加csv
- global $_SGLOBAL;
- $handle = fopen ($_FILES['mycsv']['tmp_name'],"r");
- while ($data = fgetcsv ($handle, 1000, ",")) {
- $num = count ($data);
- for ($c=0; $c < $num; $c++) {
- $inserts[] = "('$mtag[tagid]', '$data[$c]', '0', '1')";
- $_SGLOBAL['db']->query("INSERT INTO ".tname('tagspace')." (`tagid`, `passname`, `uid`, `roster`) VALUES ".implode(',', $inserts));
- }
- }
- fclose ($handle);
- showmessage('do_success', "cp.php?ac=mtag&op=manage&tagid=$tagid&subop=$_GET[subop]");
复制代码 可是咋没反应呐,麻烦指教一下阿,拜托了 |