모두 사진을 업로드하고 내 서버에 저장하려면 & 간단한 형태로 수정하고 GPS 좌표를 반환하십시오. 표준 PHP 파일 업로드 스크립트와 여기에있는 GP 솔루션을 사용하고 있습니다. 파일 업로드는 가능하지만 GPS 좌표는 반환하지 않습니다. 누구든지 문제를 파악할 수 있습니까? 내 전체 PHP는 다음과 같습니다사진을 업로드하고 GPS 좌표를 반환하는 방법
\t \t \t \t <?php
\t \t \t \t $target_dir = "uploads/";
\t \t \t \t $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
\t \t \t \t $uploadOk = 1;
\t \t \t \t $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
\t \t \t \t // Check if image file is a actual image or fake image
\t \t \t \t if(isset($_POST["submit"])) {
\t \t \t \t \t $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
\t \t \t \t \t if($check !== false) {
\t \t \t \t \t \t echo "File is an image - " . $check["mime"] . ".";
\t \t \t \t \t \t $uploadOk = 1;
\t \t \t \t \t } else {
\t \t \t \t \t \t echo "File is not an image.";
\t \t \t \t \t \t $uploadOk = 0;
\t \t \t \t \t }
\t \t \t \t }
\t \t \t \t // Check if file already exists
\t \t \t \t if (file_exists($target_file)) {
\t \t \t \t \t echo "Sorry, file already exists.";
\t \t \t \t \t $uploadOk = 0;
\t \t \t \t }
\t \t \t \t // Check file size
\t \t \t \t if ($_FILES["fileToUpload"]["size"] > 5000000000) {
\t \t \t \t \t echo "Sorry, your file is too large.";
\t \t \t \t \t $uploadOk = 0;
\t \t \t \t }
\t \t \t \t // Allow certain file formats
\t \t \t \t if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
\t \t \t \t && $imageFileType != "gif") {
\t \t \t \t \t echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
\t \t \t \t \t $uploadOk = 0;
\t \t \t \t }
\t \t \t \t // Check if $uploadOk is set to 0 by an error
\t \t \t \t if ($uploadOk == 0) {
\t \t \t \t \t echo "Sorry, your file was not uploaded.";
\t \t \t \t // if everything is ok, try to upload file
\t \t \t \t } else {
\t \t \t \t \t if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
\t \t \t \t \t \t echo "The file ". basename($_FILES["fileToUpload"]["name"]). " has been uploaded.";
\t \t \t \t \t } else {
\t \t \t \t \t \t echo "Sorry, there was an error uploading your file.";
\t \t \t \t \t }
\t \t \t \t }
\t \t \t \t read_gps_location($target_file);
\t \t \t \t /**
\t \t \t \t * Returns an array of latitude and longitude from the Image file
\t \t \t \t * @param image $file
\t \t \t \t * @return multitype:number |boolean
\t \t \t \t */
\t \t \t \t function read_gps_location(){
\t \t \t \t \t if (is_file($target_file)) {
\t \t \t \t \t \t $info = exif_read_data($target_file);
\t \t \t \t \t \t if (isset($info['GPSLatitude']) && isset($info['GPSLongitude']) &&
\t \t \t \t \t \t \t isset($info['GPSLatitudeRef']) && isset($info['GPSLongitudeRef']) &&
\t \t \t \t \t \t \t in_array($info['GPSLatitudeRef'], array('E','W','N','S')) && in_array($info['GPSLongitudeRef'], array('E','W','N','S'))) {
\t \t \t \t \t \t \t $GPSLatitudeRef = strtolower(trim($info['GPSLatitudeRef']));
\t \t \t \t \t \t \t $GPSLongitudeRef = strtolower(trim($info['GPSLongitudeRef']));
\t \t \t \t \t \t \t $lat_degrees_a = explode('/',$info['GPSLatitude'][0]);
\t \t \t \t \t \t \t $lat_minutes_a = explode('/',$info['GPSLatitude'][1]);
\t \t \t \t \t \t \t $lat_seconds_a = explode('/',$info['GPSLatitude'][2]);
\t \t \t \t \t \t \t $lng_degrees_a = explode('/',$info['GPSLongitude'][0]);
\t \t \t \t \t \t \t $lng_minutes_a = explode('/',$info['GPSLongitude'][1]);
\t \t \t \t \t \t \t $lng_seconds_a = explode('/',$info['GPSLongitude'][2]);
\t \t \t \t \t \t \t $lat_degrees = $lat_degrees_a[0]/$lat_degrees_a[1];
\t \t \t \t \t \t \t $lat_minutes = $lat_minutes_a[0]/$lat_minutes_a[1];
\t \t \t \t \t \t \t $lat_seconds = $lat_seconds_a[0]/$lat_seconds_a[1];
\t \t \t \t \t \t \t $lng_degrees = $lng_degrees_a[0]/$lng_degrees_a[1];
\t \t \t \t \t \t \t $lng_minutes = $lng_minutes_a[0]/$lng_minutes_a[1];
\t \t \t \t \t \t \t $lng_seconds = $lng_seconds_a[0]/$lng_seconds_a[1];
\t \t \t \t \t \t \t $lat = (float) $lat_degrees+((($lat_minutes*60)+($lat_seconds))/3600);
\t \t \t \t \t \t \t $lng = (float) $lng_degrees+((($lng_minutes*60)+($lng_seconds))/3600);
\t \t \t \t \t \t \t //If the latitude is South, make it negative.
\t \t \t \t \t \t \t //If the longitude is west, make it negative
\t \t \t \t \t \t \t $GPSLatitudeRef == 's' ? $lat *= -1 : '';
\t \t \t \t \t \t \t $GPSLongitudeRef == 'w' ? $lng *= -1 : '';
\t \t \t \t \t \t \t return array(
\t \t \t \t \t \t \t \t 'lat' => $lat,
\t \t \t \t \t \t \t \t 'lng' => $lng
\t \t \t \t \t \t \t);
\t \t \t \t \t \t }
\t \t \t \t \t }
\t \t \t \t \t return false;
\t \t \t \t }
\t \t \t \t ?>
무엇이 오류입니까? –
오류가 표시되지 않으면 파일 업로드 및 파일 형식에 대한 설명 만 반환됩니다. 고맙습니다. – Brad