I have a problem using a variable to extract Exif data from a photo file as follows:
1 - I use a script that uploads and stores jpg's and as it does so it creates variable '$photo' which contains the name of the jpg and the directory it is stored in.
I also set a second variable called '$thumb' which contains the name and location of a thumbnail of the jpg which is created and stored by the upload script.
2 - On completion of the upload an exif extraction script is launched which starts by using the '$photo' variable to create a variable called '$Image' which is used at various points in the script after exif extraction - for example to fetch and display the image as well store the image details in a sql database.
When I run the script it creates a PHP error saying that the 'exif_read_data' function cannot find the file.
So in the script I set some 'echo' commands to verify the contents of the variables, as well as too check that the file held by the variable exists.
This is the script code:
The printed result of this is
So the content of the variables are showing correctly and confirming they are holding the right location/filenames, and this is verified later in the script when the variable content is used to dispaly the jpg and also store its content in a sql database.
BUT the 'exif_read_data' function cannot find the files returning the error
Line 23 is the '$exif =' line above.
I have tried searching for any clues as to why this happens, and also asked various php 'experts' and not yet come up with an answer to the problem.
Can anyone here suggest a solution?? - here's hoping![Wink ;) ;)](/styles/default/xenforo/vbSmilies/Normal/wink.gif)
1 - I use a script that uploads and stores jpg's and as it does so it creates variable '$photo' which contains the name of the jpg and the directory it is stored in.
I also set a second variable called '$thumb' which contains the name and location of a thumbnail of the jpg which is created and stored by the upload script.
2 - On completion of the upload an exif extraction script is launched which starts by using the '$photo' variable to create a variable called '$Image' which is used at various points in the script after exif extraction - for example to fetch and display the image as well store the image details in a sql database.
When I run the script it creates a PHP error saying that the 'exif_read_data' function cannot find the file.
So in the script I set some 'echo' commands to verify the contents of the variables, as well as too check that the file held by the variable exists.
This is the script code:
PHP:
$Image = $photo;
echo "$photo";
echo $Image;
echo file_exists($Image) ? 'ok' : ' image file not found';
echo file_exists($photo) ? 'ok' : ' photo file not found';
echo $thumb;
echo file_exists($thumb) ? 'ok' : ' thumb file not found';
$exif = exif_read_data($photo, 0, true);
The printed result of this is
Code:
original/raleighbike.jpg - content of variable $photo (correct)
original/raleighbike.jpg - content of variable $Image (correct)
image file not found - when checking for the file in $Image (incorrect, file does exist)
photo file not found - when checking for the file in $photo (incorrect, file does exist)
thumb file not found - when checking for the file in $thumb (incorrect, file does exist)
thumbnail/thumb_raleighbike.jpg
So the content of the variables are showing correctly and confirming they are holding the right location/filenames, and this is verified later in the script when the variable content is used to dispaly the jpg and also store its content in a sql database.
BUT the 'exif_read_data' function cannot find the files returning the error
Code:
[02-Apr-2013 18:45:29 America/Chicago] PHP Warning: exif_read_data() [<a href='function.exif-read-data'>function.exif-read-data</a>]: Unable to open file in /home2/webi8726/public_html/domain.com/sqlsidebar/displayexif.php on line 23
Line 23 is the '$exif =' line above.
I have tried searching for any clues as to why this happens, and also asked various php 'experts' and not yet come up with an answer to the problem.
Can anyone here suggest a solution?? - here's hoping
![Wink ;) ;)](/styles/default/xenforo/vbSmilies/Normal/wink.gif)
Last edited: