PHP를 사용하여 mysql로 데이터를 가져오고 싶습니다. 내 프로그램은 하드 코딩 된 파일로 Excel 파일의 경로를 작성한 경우 오류없이 작동합니다. 하지만 그 시간에 업로드 기능을 사용하여 그것을 사용하려고하는 경우 하나의 오류에 직면하고있다. 내 오류는 다음과 같습니다. :PHP를 사용하여 mysql로 데이터를 엑셀로 가져오고 싶습니다.
파일 이름 C : \ WAMP \ TMP php1FC.tmp \ 나는 또한 참조를 위해 내 코드를 제공하고
읽을 수 없습니다 :
include 'config.php';
require_once 'Excel/reader.php';
$allowedExts = array("xls","xlsx");
$temp = explode(".", $_FILES["file"]["name"]);
if (in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br>";
}
else
{
$filename=$_FILES["file"]["name"] ;
$filetype=$_FILES["file"]["type"] ;
$filesize=$_FILES["file"]["size"] ;
$filetemp=$_FILES["file"]["tmp_name"];
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
$handle = fopen($filetemp, "r");
$data = new Spreadsheet_Excel_Reader();
$data->read($filetemp);
$numr=$data->sheets[0]['numRows'];
for ($i = 2; $i <= $numr ; $i++)
{
$gender=$data->sheets[0]['cells'][$i][1];
$txtname=$data->sheets[0]['cells'][$i][2];
$txtusername = $data->sheets[0]['cells'][$i][3];
$txtphone=$data->sheets[0]['cells'][$i][4];
$txtlandno=$data->sheets[0]['cells'][$i][5];
$txtwing=$data->sheets[0]['cells'][$i][6];
$txtemail=$data->sheets[0]['cells'][$i][7];
$txtflat=$data->sheets[0]['cells'][$i][8];
$intercom=$data->sheets[0]['cells'][$i][9];
$userstatus=$data->sheets[0]['cells'][$i][10];
$livestatus=$data->sheets[0]['cells'][$i][11];
$flattype=$data->sheets[0]['cells'][$i][12];
$area1=$data->sheets[0]['cells'][$i][13];
$txtbuilding=$data->sheets[0]['cells'][$i][14];
$housingloan=$data->sheets[0]['cells'][$i][15];
$txtparking=$data->sheets[0]['cells'][$i][16];
$principalopBal=$data->sheets[0]['cells'][$i][17];
$interestBal=$data->sheets[0]['cells'][$i][18];
$servicetax=$data->sheets[0]['cells'][$i][19];
$txtgym=$data->sheets[0]['cells'][$i][20];
$txtcable=$data->sheets[0]['cells'][$i][21];
$txtswim=$data->sheets[0]['cells'][$i][22];
$txtclub=$data->sheets[0]['cells'][$i][23];
$unittype=$data->sheets[0]['cells'][$i][24];
내가 무슨 문제를 이해 해달라고. 이 가져 오기 Excel 기능을 수행하고 싶습니다. 그리고 나는 사용자가 자신의 엑셀 파일을 업로드 할 수 있기를 원한다. 그래서이 문제를 도와주세요.
고마워. 내 문제가 해결 됐어. –