在我的网站上,我有一个文件输入标签来上传照片/视频.
当在移动safari中打开网站时,当我们点击文件输入时,会打开一个操作表,其中有3个选项拍摄照片或视频,选择现有并取消.
无论如何在js中确定文件是从相机拍摄的(拍摄照片或视频),还是从相机胶卷导入(选择现有的)?
当在移动safari中打开网站时,当我们点击文件输入时,会打开一个操作表,其中有3个选项拍摄照片或视频,选择现有并取消.
无论如何在js中确定文件是从相机拍摄的(拍摄照片或视频),还是从相机胶卷导入(选择现有的)?
解决方法
我有一个从这个实现的
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 [‘date’]值与实际日期时间进行比较,如果有几秒钟的差异,您可以假设它刚刚被手机拍摄.