StanLytle Posted April 26, 2009 Share Posted April 26, 2009 When images are uploaded, they are given a random file name, such as /tmp/php7cFxpG. How do I get this file name to work with exif_read_data? Here's what I have that doesn't work: $exif = exif_read_data('$File', 'IFD0'); if ($exif == true) { $exif = exif_read_data('$File', 0, true); foreach ($exif as $key => $section) { $model = $exif['IFD0']['Model']; $iso = $exif['EXIF']['ISOSpeedRatings']; $exposure = $exif['EXIF']['ExposureTime'].' sec'; $fstop = $exif['COMPUTED']['ApertureFNumber']; $focallength = intval($exif['EXIF']['FocalLength']).' mm'; $focallength35mm = intval($exif['EXIF']['FocalLengthIn35mmFilm']).' mm'; } echo "Model: $model<br/>"; echo "ISO: $iso<br/>"; echo "Shutter Speed: $exposure<br/>"; echo "f Stop: $fstop<br/>"; echo "Focal Length: $focallength<br/>"; echo "Focal Length 35mm: $focallength35mm<br/>"; $PhotoExif = $model . ", ISO " . $iso . ", " . $exposure. ", " . $fstop. ", " . $focallength; } else { $PhotoExif = ""; } Thanks Link to comment https://forums.phpfreaks.com/topic/155669-cant-read-exif-data/ Share on other sites More sharing options...
ToonMariner Posted April 26, 2009 Share Posted April 26, 2009 have you looked at the $_FILES array? it has a 'tmp_name' index... so $_FILES['upfile']['tmp_name'] should return what you need (substitue upfile for what ever you used as your file input element name in your form... Link to comment https://forums.phpfreaks.com/topic/155669-cant-read-exif-data/#findComment-819337 Share on other sites More sharing options...
DarkWater Posted April 26, 2009 Share Posted April 26, 2009 You have $File wrapped in single quotes. Remove the quotation marks. Link to comment https://forums.phpfreaks.com/topic/155669-cant-read-exif-data/#findComment-819341 Share on other sites More sharing options...
StanLytle Posted April 26, 2009 Author Share Posted April 26, 2009 I'm not sure if I did what you suggested correctly, but it didn't work either. Here's what I tried: $exif = exif_read_data('$_FILES[File][$File]', 'IFD0'); if ($exif == true) { $exif = exif_read_data('$_FILES[File][$File]', 0, true); foreach ($exif as $key => $section) { $model = $exif['IFD0']['Model']; $iso = $exif['EXIF']['ISOSpeedRatings']; $exposure = $exif['EXIF']['ExposureTime'].' sec'; $fstop = $exif['COMPUTED']['ApertureFNumber']; $focallength = intval($exif['EXIF']['FocalLength']).' mm'; $focallength35mm = intval($exif['EXIF']['FocalLengthIn35mmFilm']).' mm'; } echo "Model: $model<br/>"; echo "ISO: $iso<br/>"; echo "Shutter Speed: $exposure<br/>"; echo "f Stop: $fstop<br/>"; echo "Focal Length: $focallength<br/>"; echo "Focal Length 35mm: $focallength35mm<br/>"; $PhotoExif = $model . ", ISO " . $iso . ", " . $exposure. ", " . $fstop. ", " . $focallength; } else { $PhotoExif = ""; } Thanks Link to comment https://forums.phpfreaks.com/topic/155669-cant-read-exif-data/#findComment-819348 Share on other sites More sharing options...
DarkWater Posted April 26, 2009 Share Posted April 26, 2009 Stop putting variables in single quotes (' '). They don't interpolate in single quotes, so they're not expanded into their stored value. Link to comment https://forums.phpfreaks.com/topic/155669-cant-read-exif-data/#findComment-819350 Share on other sites More sharing options...
StanLytle Posted April 26, 2009 Author Share Posted April 26, 2009 And I tried removing the single quotes. Still doesn't work: $exif = exif_read_data($File, 'IFD0'); if ($exif == true) { $exif = exif_read_data($File, 0, true); foreach ($exif as $key => $section) { $model = $exif['IFD0']['Model']; $iso = $exif['EXIF']['ISOSpeedRatings']; $exposure = $exif['EXIF']['ExposureTime'].' sec'; $fstop = $exif['COMPUTED']['ApertureFNumber']; $focallength = intval($exif['EXIF']['FocalLength']).' mm'; $focallength35mm = intval($exif['EXIF']['FocalLengthIn35mmFilm']).' mm'; } echo "Model: $model<br/>"; echo "ISO: $iso<br/>"; echo "Shutter Speed: $exposure<br/>"; echo "f Stop: $fstop<br/>"; echo "Focal Length: $focallength<br/>"; echo "Focal Length 35mm: $focallength35mm<br/>"; $PhotoExif = $model . ", ISO " . $iso . ", " . $exposure. ", " . $fstop. ", " . $focallength; } else { $PhotoExif = ""; } Thanks Link to comment https://forums.phpfreaks.com/topic/155669-cant-read-exif-data/#findComment-819353 Share on other sites More sharing options...
ToonMariner Posted April 26, 2009 Share Posted April 26, 2009 still don't see you using tmp_name yet... have you read the documentation on super globals? Link to comment https://forums.phpfreaks.com/topic/155669-cant-read-exif-data/#findComment-819477 Share on other sites More sharing options...
StanLytle Posted April 26, 2009 Author Share Posted April 26, 2009 Some success! What was missing were foreach statements. At least thats what made it work. I can extract the data, even though the data isn't output in the format I want: $exif = exif_read_data($File, 'IFD0'); if ($exif == true) { $exif = exif_read_data($File, 0, true); foreach ($exif as $key => $section) { foreach ($section as $name => $val) { $model = $exif['IFD0']['Software']; $iso = $exif['EXIF']['ISOSpeedRatings']; $exposure = $exif['EXIF']['ExposureTime'].' sec'; $fstop = $exif['COMPUTED']['ApertureFNumber']; $focallength = intval($exif['EXIF']['FocalLength']).' mm'; $focallength35mm = intval($exif['EXIF']['FocalLengthIn35mmFilm']).' mm'; } } if ($model == "K10D ") { $model = "Pentax K10D"; } $PhotoExif = $model . ", ISO " . $iso . ", " . $exposure. ", " . $fstop. ", " . $focallength; } Now the problem is that I can't change the value of $model from "K10D space" to "Pentax K10D". Link to comment https://forums.phpfreaks.com/topic/155669-cant-read-exif-data/#findComment-819509 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.