JamesAB
07-13-2015, 11:32 PM
This isn't for a modification. This is a problem I'm having with the stock VB 3.8.7 code.
I have attachments stored in the file system and I'm not using the lightbox feature. When a user clicks on a photo it opens by itself. However, if the user tries to save the photo, the filename is always "attachment.php" and not the actual file name.
This has been a problem in Internet Explorer for quite a while. The only workaround I knew of was to view the forum in "compatibility" mode in IE.
Now this has also become a problem in Firefox 39. Previous versions of Firefox didn't have this issue. When you tried to save a photo in Firefox 38, the correct file name was displayed in the "Save As" dialog box.
I believe this is the part of attachment.php that is causing the problem:
// Opera and IE have not a clue about this, mozilla puts on incorrect extensions.
if (is_browser('mozilla'))
{
$filename = "filename*=" . $filename_charset . "''" . rawurlencode($filename);
//$filename = "filename==?$stylevar[charset]?B?" . base64_encode($filename) . "?=";
}
else
{
// other browsers seem to want names in UTF-8
if ($filename_charset != 'utf-8' AND function_exists('iconv'))
{
$filename_conv = iconv($filename_charset, 'UTF-8//IGNORE', $filename);
if ($filename_conv !== false)
{
$filename = $filename_conv;
}
}
if (is_browser('opera') OR is_browser('konqueror') OR is_browser('safari'))
{
// Opera / Konqueror does not support encoded file names
$filename = 'filename="' . str_replace('"', '', $filename) . '"';
}
else
{
// encode the filename to stay within spec
$filename = 'filename="' . rawurlencode($filename) . '"';
}
}
if (in_array($extension, array('jpg', 'jpe', 'jpeg', 'gif', 'png')))
{
header("Content-disposition: inline; $filename");
header('Content-transfer-encoding: binary');
}
else
{
// force files to be downloaded because of a possible XSS issue in IE
header("Content-disposition: attachment; $filename");
}
I've tried changing the Content-disposition: by changing the $filename variable and have found combinations that work in IE so that the correct filename is displayed in the "Save As" box instead of attachment.php.
I haven't found any fix that will make this code work correctly with Firefox 39.
Any ideas?
All help is appreciated.
Thanks,
James
I have attachments stored in the file system and I'm not using the lightbox feature. When a user clicks on a photo it opens by itself. However, if the user tries to save the photo, the filename is always "attachment.php" and not the actual file name.
This has been a problem in Internet Explorer for quite a while. The only workaround I knew of was to view the forum in "compatibility" mode in IE.
Now this has also become a problem in Firefox 39. Previous versions of Firefox didn't have this issue. When you tried to save a photo in Firefox 38, the correct file name was displayed in the "Save As" dialog box.
I believe this is the part of attachment.php that is causing the problem:
// Opera and IE have not a clue about this, mozilla puts on incorrect extensions.
if (is_browser('mozilla'))
{
$filename = "filename*=" . $filename_charset . "''" . rawurlencode($filename);
//$filename = "filename==?$stylevar[charset]?B?" . base64_encode($filename) . "?=";
}
else
{
// other browsers seem to want names in UTF-8
if ($filename_charset != 'utf-8' AND function_exists('iconv'))
{
$filename_conv = iconv($filename_charset, 'UTF-8//IGNORE', $filename);
if ($filename_conv !== false)
{
$filename = $filename_conv;
}
}
if (is_browser('opera') OR is_browser('konqueror') OR is_browser('safari'))
{
// Opera / Konqueror does not support encoded file names
$filename = 'filename="' . str_replace('"', '', $filename) . '"';
}
else
{
// encode the filename to stay within spec
$filename = 'filename="' . rawurlencode($filename) . '"';
}
}
if (in_array($extension, array('jpg', 'jpe', 'jpeg', 'gif', 'png')))
{
header("Content-disposition: inline; $filename");
header('Content-transfer-encoding: binary');
}
else
{
// force files to be downloaded because of a possible XSS issue in IE
header("Content-disposition: attachment; $filename");
}
I've tried changing the Content-disposition: by changing the $filename variable and have found combinations that work in IE so that the correct filename is displayed in the "Save As" box instead of attachment.php.
I haven't found any fix that will make this code work correctly with Firefox 39.
Any ideas?
All help is appreciated.
Thanks,
James