我刚开始使用 php 并且在过去的几天里完全被难住了。我正在尝试提取和使用从 $_FILES 中的多个数组中提取的键值对。我敢肯定这是一个荒谬的愚蠢问题,但我很难过。如果我运行以下代码,我会得到以下结果。
$exif = exif_read_data('/uploads/'.$file['name'], 0, true);
foreach($_FILES as $file){
echo $file['name'] . " :<br />\n";
foreach ($exif as $key => $section) {
foreach ($section as $name => $val) {
echo "<pre>This is \$name" . $name ."<br>";
echo "<pre>This is \$val" . $val ."<br>";
}
}
}
以下是输出:
上传图片
Image contains headers
Across the Field - LK.jpg :
FILE.FileName: Across the Field - LK.jpg
FILE.FileDateTime: 1361055472
FILE.FileSize: 294785
FILE.FileType: 2
FILE.MimeType: image/jpeg
FILE.SectionsFound: ANY_TAG, IFD0, THUMBNAIL, EXIF
COMPUTED.html: width="700" height="525"
COMPUTED.Height: 525
COMPUTED.Width: 700
COMPUTED.IsColor: 1
COMPUTED.ByteOrderMotorola: 0
COMPUTED.ApertureFNumber: f/9.0
COMPUTED.Copyright: Copyright 2010
IFD0.ImageWidth: 1024
IFD0.ImageLength: 768
IFD0.BitsPerSample: Array
IFD0.PhotometricInterpretation: 2
IFD0.Model: NIKON D300
IFD0.Orientation: 1
IFD0.SamplesPerPixel: 3
IFD0.XResolution: 720000/10000
IFD0.YResolution: 720000/10000
IFD0.ResolutionUnit: 2
IFD0.Software: Adobe Photoshop CS5 Windows
IFD0.DateTime: 2013:01:24 16:33:16
IFD0.Artist: lken
IFD0.Copyright: Copyright 2010
IFD0.Exif_IFD_Pointer: 316
THUMBNAIL.Compression: 6
THUMBNAIL.XResolution: 72/1
THUMBNAIL.YResolution: 72/1
THUMBNAIL.ResolutionUnit: 2
THUMBNAIL.JPEGInterchangeFormat: 642
THUMBNAIL.JPEGInterchangeFormatLength: 0
EXIF.ExposureTime: 1/100
EXIF.FNumber: 9/1
EXIF.ISOSpeedRatings: 400
EXIF.ExifVersion: 0221
EXIF.DateTimeOriginal: 2010:08:15 05:57:17
EXIF.DateTimeDigitized: 2010:08:15 05:57:17
EXIF.ShutterSpeedValue: 6643856/1000000
EXIF.ApertureValue: 633985/100000
EXIF.FocalLength: 1700/100
EXIF.ColorSpace: 65535
EXIF.ExifImageWidth: 700
EXIF.ExifImageLength: 525
为简洁起见,我省略了第二张照片中的数据。
以下是 $_FILES 的输出:
Array
(
[userfile] => Array
(
[name] => Across the Field - LK.jpg
[type] => image/jpeg
[tmp_name] => C:\wamp\tmp\php223.tmp
[error] => 0
[size] => 294785
)
[userfile1] => Array
(
[name] => autumn-panorama - lk.jpg
[type] => image/jpeg
[tmp_name] => C:\wamp\tmp\php224.tmp
[error] => 0
[size] => 106349
)
)
我查看了每个站点和我能找到的每本书,以找到如何访问名称值对(例如 IFD0.ImageWidth: 1024 和 IFD0.ImageLength: 768 ),因此我可以设置对上传大小等的限制。
我现在很困惑,将不胜感激任何帮助或指导。特别感谢资源。谢谢你。