![](/img/trans.png)
[英]Removing index.php from CodeIgniter url redirects to localhost
[英]after import csv file, redirects to http://localhost/index.php
好的,我已經制作了一個頁面來導入我的股票文件,該文件位於.csv
文件中(可以正常工作),但是導入完成后,該頁面直接進入我的localhost/index.php
而不是返回“好”消息...那是為什么?
這是代碼:
<form enctype="multipart/form-data" method="post" role="form">
<div class="form-group">
<label for="exampleInputFile">Importar archivo</label>
<input type="file" name="file" id="file" size="150">
<p class="help-block">Solo archivos .csv</p>
</div>
<button type="submit" class="btn btn-default" name="Import" value="Import">Importar</button>
</form>
<input type="button" onclick=" location.href='http://localhost/inicio.html' " value="Inicio" name="boton" />
<?php
if(isset($_POST["Import"]))
{
//me conecto a la BD
$conexion=mysql_connect("localhost","root","") or die("Problemas en la conexion");
mysql_select_db("kontor",$conexion) or die("Problemas en la seleccion de la base de datos");
echo $filename=$_FILES["file"]["tmp_name"];
if($_FILES["file"]["size"] > 0)
{
$file = fopen($filename, "r");
$count = 0;
while (($emapData = fgetcsv($file, 10000, ";", '"')) !== FALSE)
{
$count++;
if($count>1){
mysql_query("INSERT into stock (SKU,nombre,descr,prbruto,prneto,fechaing,cantcentral,cantarauco,cantdrug,canttrebol) values ('$emapData[0]','$emapData[1]','$emapData[2]','$emapData[3]','$emapData[4]','$emapData[5]','$emapData[6]','$emapData[7]','$emapData[8]','$emapData[9]')", $conexion) or die("Problemas en el select: ".mysql_error());
}
}
fclose($file);
echo 'Archivo importado';
header('Location: index.php');
}
else
echo 'Formato de archivo incorrecto';
}
?>
刪除header('Location: index.php');
從您的代碼。
這導致了重定向。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.