1
There is a logic error in the class called photoHandler.php when the user tries to upload a photo where the filename of the image contains dots.
Look for this statement in the function called _makeFileName in photoHandler.php in the class folder:
$fileName = explode(".",$fileName);
This splits the filename into 2 parts when the first “.” Is encountered:
• $fileName[0]
• $fileName[1]
This is OK when we have a filename such as IMG_8517.JPG - $fileName[0] will be
IMG_8517 and $fileName[1] will be
JPG.
However, if the user has renamed the file to something like: wedding.bill.and.mary.jpg, then $fileName[0] will be
wedding and $fileName[1] will be
bill. In other words, the files will be stored with the wrong filetype. This causes problems when a user tries to download the original image because it will be saved with a filetype of
bill instead of a filetype of
jpg.
To address this problem we need to separate the filename from the filetype. Fortunately there is a simple PHP function to help us do this – pathinfo.
My suggested changes are to add these statements at the start of the _makeFileName function:
$path_parts = pathinfo($fileName);
$fname = $path_parts['filename'];
$ftype = $path_parts['extension'];
You can then adjust the rest of the code to use $fname and $ftype as appropriate.
Regards, Tom O’Dea
Regards, Tom O'Dea
Melbourne, Australia