Cannot upload images
-
I was not able to upload images to a photo gallery. It was giving the error: “There has been a problem while trying to upload the following images. Please try to upload them again.”. I am using the latest version of the Photo Gallery plugin.
I checked using Chrome developers toolbox and it showed 500 internet server error for the ajax call: bwg_UploadHandler. I checked the code of filemanager/UploadHandler.php, which was handling the ajax call. I used Php print and echo commands to locate the error. It turned out the problem was in the function set_file_info. The function was not handling the case where an image has no credit, aperture, camera, caption, iso, copyright or tags. So if an image has an empty value for one of these properties, then the ajax call fails. I updated the function set_file_info so it checks if the file properties are present. That fixed the error. I was able to upload images. Here is the updated code for set_file_info:
/** * Set file info. * * @param $info * @return mixed */ private function set_file_info( $info ) { $data['is_dir'] = 0; $data['path'] = $info->path; $data['type'] = $info->type; $data['name'] = $info->name; $data['filename'] = $info->filename; $data['alt'] = $info->alt; $data['thumb'] = 'thumb/' . $info->name; $data['size'] = $info->size; $data['resolution'] = $info->resolution; $data['credit'] = iconv_mime_decode($info->credit); $data['aperture'] = iconv_mime_decode($info->aperture); $data['camera'] = iconv_mime_decode($info->camera); $data['caption'] = iconv_mime_decode($info->caption); $data['iso'] = iconv_mime_decode($info->iso); $data['orientation'] = $info->orientation; $data['copyright'] = iconv_mime_decode($info->copyright); $data['tags'] = iconv_mime_decode($info->tags); $data['date_modified'] = date('Y-m-d H:i:s'); return $data; }
Please fix this issue and update your plugin. Thanks
The page I need help with: [log in to see the link]
- The topic ‘Cannot upload images’ is closed to new replies.