在我的网站上,我有file input
标记来上传照片/视频。
在移动版Safari中打开网站时,当我们点击文件输入时,会打开一个操作表,其中包含3个选项take photo or Video
,choose Existing
和cancel
。
无论如何在js中确定文件是从相机(take photo or video
)中取出的,还是从相机胶卷中导入的(choose existing
)?
答案 0 :(得分:0)
我已经实现了一个php解决方案,我不确定这会对你有所帮助,但这里是代码:
<?php
$camera = cameraUsed("C:\Users\Ale\Pictures\sep7imodia.jpg");
echo "Camera Used: " . $camera['make'] . " " . $camera['model'] . "<br />";
echo "Exposure Time: " . $camera['exposure'] . "<br />";
echo "Aperture: " . $camera['aperture'] . "<br />";
echo "ISO: " . $camera['iso'] . "<br />";
echo "Date Taken: " . $camera['date'];
// This function is used to determine the camera details for a specific image. It returns an array with the parameters.
function cameraUsed($imagePath) {
// Check if the variable is set and if the file itself exists before continuing
if ((isset($imagePath)) and (file_exists($imagePath))) {
// There are 2 arrays which contains the information we are after, so it's easier to state them both
$exif_ifd0 = read_exif_data($imagePath ,'IFD0' ,0);
$exif_exif = read_exif_data($imagePath ,'EXIF' ,0);
//error control
$notFound = "Unavailable";
// Make
if (@array_key_exists('Make', $exif_ifd0)) {
$camMake = $exif_ifd0['Make'];
} else { $camMake = $notFound; }
// Model
if (@array_key_exists('Model', $exif_ifd0)) {
$camModel = $exif_ifd0['Model'];
} else { $camModel = $notFound; }
// Exposure
if (@array_key_exists('ExposureTime', $exif_ifd0)) {
$camExposure = $exif_ifd0['ExposureTime'];
} else { $camExposure = $notFound; }
// Aperture
if (@array_key_exists('ApertureFNumber', $exif_ifd0['COMPUTED'])) {
$camAperture = $exif_ifd0['COMPUTED']['ApertureFNumber'];
} else { $camAperture = $notFound; }
// Date
if (@array_key_exists('DateTime', $exif_ifd0)) {
$camDate = $exif_ifd0['DateTime'];
} else { $camDate = $notFound; }
// ISO
if (@array_key_exists('ISOSpeedRatings',$exif_exif)) {
$camIso = $exif_exif['ISOSpeedRatings'];
} else { $camIso = $notFound; }
$return = array();
$return['make'] = $camMake;
$return['model'] = $camModel;
$return['exposure'] = $camExposure;
$return['aperture'] = $camAperture;
$return['date'] = $camDate;
$return['iso'] = $camIso;
return $return;
} else {
return false;
}
}
?>
您可以将$ camera [&#39; date&#39;]值与实际日期时间进行比较,如果有几秒钟差异,您可以认为它刚刚被手机拍摄。