2011-07-11 193 views
2
$file=$_FILES['import']['name']; 
     $path='C:/Documents and Settings/Administrator/My Documents/Downloads'.$file; 
echo $file.'hi'; 
     $dbhost = 'localhost'; 
    $dbuser = 'root'; 
    $dbpass = ''; 
    $dbname = 'test1'; 
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); 

mysql_select_db($dbname); 

    // Dump table. 
// $query = "DROP TABLE location"; 
// $result = @mysql_query ($query); //runs the query 

// if (mysql_affected_rows() == 1) { //if it ran ok. 
// 
// echo '<p>The database was updated</p>'; 
// exit(); 
// 
// } else { // if did not run ok. 
// $message = '<p>The database was not updated</p>'; 
// } // end table dump. 

    // Create table call_in. 
// $query = "CREATE TABLE location1(id int(255) NOT NULL AUTO_INCREMENT,lat VARCHAR(100),long VARCHAR(100),PRIMARY KEY(id))"; 
$query="CREATE TABLE `test1`.`location1` (
`id` INT(255) NOT NULL AUTO_INCREMENT , 
`lat` VARCHAR(1000) NOT NULL , 
`long` VARCHAR(1000) NOT NULL , 
`speed` VARCHAR(1000) NOT NULL , 
`time` DATETIME NOT NULL , 
`address` VARCHAR(1000) NOT NULL , 
PRIMARY KEY (`id`) 
) ENGINE = InnoDB;"; 
    $result = @mysql_query ($query); //runs the query 

    $query = "LOAD DATA LOCAL INFILE 'D:/technoho_360gps-sqldump.sql' INTO TABLE `location1` FIELDS TERMINATED BY '\', \'' LINES TERMINATED BY '\n' STARTING BY 'INSERT'"; 
    $result = @mysql_query ($query); //runs the query 
    echo 'hello'; 

    mysql_close(); // close the database connection. 
    } 

在此代碼中,我給出了靜態系統路徑,但我希望從文件標記獲得系統文件路徑。從文件標記中獲取系統文件路徑

+1

什麼文件標籤。?請詳細解釋。 – Chandresh

+0

我想要這個文件標籤選擇的文件的路徑。 – srbhbarot

回答

0

如果您從用戶端(即瀏覽器的結尾)討論上傳文件的文件路徑,則不可能。

您只能使用php獲取服務器中上傳文件路徑的路徑。 瀏覽器策略不允許您獲取用戶磁盤上文件的實際路徑。

+0

感謝您的回覆。 – srbhbarot