[Vtigercrm-developers] New patch for utf-8 characters (ticket 2876)
René Herrmann
rene.herrmann at gmx.ch
Mon Feb 19 06:00:52 PST 2007
Hi all, I made some modifications to my vtiger version 5.0.2, I hope
you can review this and maybe check it in:
(sorry for posting this here but I do not have access to the bug-tracker)
Issue: corrupt downloads of huge zips (like 50MB for example) on IE
6.0/7.0 or Mozilla and wrong filenames (like index.php instead of
file1.zip). By the way I put the filepath into a session variable
instead of the whole file content (50MB and more caused some problems
for a session variable).
If you like, I could check this in by myself. I have some more changes
I like to comit too, which we can discuss.
Thank you,
René Herrmann
/support/index.php (do the same for /modules/uploads/downloads.php)
Some additional headers fix this (by the way I also put the filepath
into a session variable):
(...)
if($_REQUEST['downloadfile'] == 'true')
{
$filename = $_REQUEST['filename'];
$fileType = $_REQUEST['filetype'];
$fileid = $_REQUEST['fileid'];
$filesize = $_REQUEST['filesize'];
$contentname = $fileid.'_filecontents';
//$fileContent = $_SESSION[$contentname];
$filesize = $_REQUEST['filesize'];
// ### REH, Jan 2007
//$filepath = base64_decode($_REQUEST['filepath']);
$filepath = $_SESSION[$contentname];
//$filepath = $_REQUEST['filepath'];
//header('"Content-Disposition: attachment;
filename="'.$filename.'"');
// ## REH, Jan 2007
// These headers make the filename available to IE which
makes troubles
header("Content-Description: PHP Generated Data");
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
//header("Content-length: $filesize");
//header('Content-Disposition: inline; filename="'.$filename.'"');
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Content-Transfer-Encoding: binary");
$fileContent = fread(fopen($filepath, "r"), $filesize);
echo($fileContent);
exit;
}
(...)
/support/Tickets/ticketDetail.php
I put the filepath into a session variable:
(...)
//Get the attachments list and form in the tr tag
$files_array = getTicketAttachmentsList($ticketid);
$attachments_count = count($files_array);
if(is_array($files_array))
{
for($j=0;$j<$attachments_count;$j++)
{
$filename = $files_array[$j]['filename'];
$filetype = $files_array[$j]['filetype'];
$filesize = $files_array[$j]['filesize'];
$fileid = $files_array[$j]['fileid'];
$filecontents = $files_array[$j]['filecontents'];
$contentname = $fileid.'_filecontents';
// ### new return value, REH, Jan 2007
$filepath = '../'.$files_array[$j]['filepath'];
// ### Putting the filecontent into the Session is nonsense
//$_SESSION[$contentname] = $filecontents;
// We take the filepath instead
$_SESSION[$contentname] = $filepath;
//To display the attachments title
$attachments_title = '';
if($j == 0)
$attachments_title = '<b>Attachment(s) : </b>';
$list .= '
<tr>
<td class="dvtCellLabel"
align="right">'.$attachments_title.'</td>
<td class="dvtCellInfo" colspan="3">
<a
href="index.php?downloadfile=true&fileid='.$fileid.'&filename='.$filename.'&filesize='.$filesize.'&filetype='.$filetype.'">'.ltrim($filename,$ticketid.'_').'
</a></td>
</tr>';
}
}
(...)
More information about the vtigercrm-developers
mailing list