|
|
|
สอบถามเรื่องการอัพโหลดภาพ gps Exif file + php จะต้องทำอย่างไรคะ |
|
|
|
|
|
|
|
ขอสอบถามคะ คือตอนนี้สามารถอัพโหลดภาพที่มี gps และลง gps ในฐานข้อมูลได้ แต่ว่า ถ้าอัพโหลดภาพไม่มี Gps จะแสดง Error แต่ลงฐานข้อมูลเป็น 0 มีวิธีแก้ไขอย่างไรบ้างคะ
Err
Notice: Undefined offset: 0 in C:\xampp\htdocs\p\insert.php on line 69
Notice: Undefined offset: 1 in C:\xampp\htdocs\p\insert.php on line 69
Notice: Undefined offset: 2 in C:\xampp\htdocs\p\insert.php on line 69
Notice: Undefined index: GPSLongitude in C:\xampp\htdocs\p\insert.php on line 74
Notice: Undefined index: GPSLongitudeRef in C:\xampp\htdocs\pr\insert.php on line 74
Pull GPS from Photo (PHP)
if(file_exists($path)){
$details = exif_read_data($path);
$sections = explode(',',$details['SectionsFound']);
if(in_array('GPS',array_flip($sections))){
}else{
die('GPS data not found');
}
}else{
die('File does not exists');
}
function format_gps_data($gpsdata,$lat_lon_ref){
$gps_info = array();
foreach($gpsdata as $gps){
list($j , $k) = explode('/', $gps);
array_push($gps_info,$j/$k);
}
$coordination = $gps_info[0] + ($gps_info[1]/60.00) + ($gps_info[2]/3600.00);
return (($lat_lon_ref == "S" || $lat_lon_ref == "W" ) ? '-'.$coordination : $coordination).' '.$lat_lon_ref;
}
$Lat = format_gps_data($details['GPSLatitude'],$details['GPSLatitudeRef']);
$Lon = format_gps_data($details['GPSLongitude'],$details['GPSLongitudeRef']);
if($path != ""){
$exif_date = exif_read_data($path);
$edate = $exif_date['DateTime'];
}
Tag : PHP, HTML/CSS, CakePHP
|
|
|
|
|
|
Date :
2017-04-04 23:37:02 |
By :
Jsk |
View :
912 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
if(file_exists($path)){
$details = exif_read_data($path);
$sections = explode(',',$details['SectionsFound']);
if(isset($details['SectionsFound']))
{
if(in_array('GPS',array_flip($sections))){
}else{
die('GPS data not found');
}
}else{
die('File does not exists');
}
function format_gps_data($gpsdata,$lat_lon_ref){
$gps_info = array();
foreach($gpsdata as $gps){
list($j , $k) = explode('/', $gps);
array_push($gps_info,$j/$k);
}
$coordination = $gps_info[0] + ($gps_info[1]/60.00) + ($gps_info[2]/3600.00);
return (($lat_lon_ref == "S" || $lat_lon_ref == "W" ) ? '-'.$coordination : $coordination).' '.$lat_lon_ref;
}
$Lat = format_gps_data($details['GPSLatitude'],$details['GPSLatitudeRef']);
$Lon = format_gps_data($details['GPSLongitude'],$details['GPSLongitudeRef']);
if($path != ""){
$exif_date = exif_read_data($path);
$edate = $exif_date['DateTime'];
}
}
|
|
|
|
|
Date :
2017-04-05 09:44:59 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มันยังขึ้น error เหมือนเดิมคะ หรือถ้าจะให้ตอนใส่ภาพที่ไม่มี gps ให้มันแสดง popup กลับไปยังหน้า insert ข้อมูลได้ไหมคะ หรือพอจะมีวิธีอื่นไหมคะ
นี้คือโค๊ดคะ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>map</title>
</head>
<p align="center"><b>Thank You </b></font></p>
<?php
//----> Uploag to Folder name >> Photo
if(move_uploaded_file($_FILES["file1"]["tmp_name"],"Photo/".$_FILES["file1"]["name"]))
{
echo "<p align='center'><font color='#FFFFFF' size='+2'><b>Upload Completed</b></font></p>";
}
//----> Show Picture Data
if($_FILES["file1"]["error"]>0){
echo "Error : ".$_FILES["file1"]["error"]."<br>";
}else{
echo "<table width='/200 border='2' bordercolor='#FFFFFF' align='center'>";
echo "<tr>";
echo "<td><<b>File Name : </b>".$_FILES["file1"]["name"]."</td>";
echo "</tr>";
echo "<tr>";
echo "<td><b>Type : </b>".$_FILES["file1"]["type"]."</td>";
echo "</tr>";
echo "<tr>";
echo "<td><b>Size : </b>".($_FILES["file1"]["size"]/1024)." KB</td>";
echo "</tr>";
//echo "Stored in : ".$_FILES["file1"]["tmp_name"];
}
$filename = @$_FILES["file1"]["name"];
$path = 'Photo/'.$filename;
$area = @$_POST["Area"];
//---->Pull GPS from Photo
if(file_exists($path)){
$details = exif_read_data($path);
$sections = explode(',',$details['SectionsFound']);
if(in_array('GPS',array_flip($sections))){
}else{
die('GPS data not found');
}
}else{
die('File does not exists');
}
function format_gps_data($gpsdata,$lat_lon_ref){
$gps_info = array();
foreach($gpsdata as $gps){
list($j , $k) = explode('/', $gps);
array_push($gps_info,$j/$k);
}
$coordination = $gps_info[0] + ($gps_info[1]/60.00) + ($gps_info[2]/3600.00);
return (($lat_lon_ref == "S" || $lat_lon_ref == "W" ) ? '-'.$coordination : $coordination).' '.$lat_lon_ref;
}
$Lat = format_gps_data($details['GPSLatitude'],$details['GPSLatitudeRef']);
$Lon = format_gps_data($details['GPSLongitude'],$details['GPSLongitudeRef']);
if($path != ""){
$exif_date = exif_read_data($path);
$edate = $exif_date['DateTime'];
}
echo "<tr>";
echo "<td><font color='#FFFFFF'><b>Latitude : </b>".$edate."</font></td>" ;
echo "</tr>";
echo "<tr>";
echo "<td><font color='#FFFFFF'><b>Latitude : </b>".$Lat."</font></td>" ;
echo "</tr>";
echo "<tr>";
echo "<td><font color='#FFFFFF'><b>Longitude : </b>".$Lon."</font></td>" ;
echo "</tr>";
echo "<tr>";
echo "<td><font color='#FFFFFF'><b>Date/Time : </b></font></td>" ;
echo "</tr>";
?>
<table width='400' border='0' align='center'>
<tr>
<td>
<p align="center"><a href="Map.php?abc=<?=$path;?>"><img src="images/google-maps.png" width="140" height="140"></a></p>
<p align="center"><b>View on Map</b></font></p>
</td>
</tr>
</table>
<?php
require_once 'Connect.php';
$sql = "insert into $tbname set Photoname='$filename',Photopath='$path,'Area='$area',Date='$edate',Lat='$Lat',Lon='$Lon'";
mysql_query($sql)or die ('eror');
mysql_close();
?>
</body>
</html>
|
|
|
|
|
Date :
2017-04-05 19:00:20 |
By :
Jsk |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|