get system file path from file tag
$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(i开发者_如何学运维d 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.
}
In this code i have given static system path but i want system file path from file tag.
If you are talking about the file path of the uploaded file from the user's end, i.e., browser's end, it is not possible.
You can only get the path of the uploaded file path in the server using php. Browser policy don't allow you to get the actual path of the file on the disk of the user.
精彩评论