从文件标签获取系统文件路径

时间:2011-07-11 07:07:27

标签: php file path

$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 个答案:

答案 0 :(得分:0)

如果您正在谈论用户端的上传文件的文件路径,即浏览器的结尾,则无法进行。

您只能使用php获取服务器中上传文件路径的路径。 浏览器策略不允许您获取用户磁盘上文件的实际路径。