Script URL:
Version of script: 2.4.2
Hosting company:
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:
Write your message below:
hello,
there is the possibility of opening attachments .pdf or image on a page .html rather than download it as a download?
Open attachments on page.html
Moderator: mkoch227
Re: Open attachments on page.html
I strongly discourage doing that. The reason attachments are hidden then read and forced as a download is to make sure no malicious code can be executed.
You could open them directly in browser by modifying download_attachments.php file. Just ABOVE the very first line starting with you could use something like
This will open attachments with the extensions listed directly in browser.
But again, I really discourage doing this. Use at your own risk.
You could open them directly in browser by modifying download_attachments.php file. Just ABOVE the very first line starting with
Code: Select all
header(
Code: Select all
$open_directly = array(
'pdf',
'jpg',
'jpeg',
'gif',
'png',
'txt',
);
if ( isset($open_directly[strtolower(pathinfo($file['real_name'], PATHINFO_EXTENSION))]) )
{
header('Location: ' . $realpath);
exit();
}
But again, I really discourage doing this. Use at your own risk.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: Open attachments on page.html
Thanks Klemen but i dont find header in file download_attachments.php.
If i undestand will erase all content and put this code?
Is this?
If i undestand will erase all content and put this code?
Is this?
Re: Open attachments on page.html
No, it's definitely there inside the "download_attachment.php" file.
Should be towards the end of the file, several lines starting with header and this code should go just above the first header line.
Make sure you open the source file inside a text editor.
Should be towards the end of the file, several lines starting with header and this code should go just above the first header line.
Make sure you open the source file inside a text editor.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: Open attachments on page.html
thanks Klemen but put only the code after Header, files open with 0 size.
Some idea?
part of file after line 122:
/* Send the file as an attachment to prevent malicious code from executing */
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Length: ' . $file['size']);
header('Content-Disposition: attachment; filename=' . $file['real_name']);
$open_directly = array(
'pdf',
'jpg',
'jpeg',
'gif',
'png',
'txt',
);
if ( isset($open_directly[strtolower(pathinfo($file['real_name'], PATHINFO_EXTENSION))]) )
{
header('Location: ' . $realpath);
exit();
}
/*
$realpath = $hesk_settings['server_path'].'/attachments/'.$file['saved_name'];
$chunksize = 1 * (1024 * 1024);
if ($file['size'] > $chunksize)
{
$handle = fopen($realpath, 'rb');
$buffer = '';
while ( ! feof($handle))
{
set_time_limit(300);
$buffer = fread($handle, $chunksize);
echo $buffer;
flush();
}
fclose($handle);
}
else
{
readfile($realpath);
}
exit();*/
?>
Some idea?
part of file after line 122:
/* Send the file as an attachment to prevent malicious code from executing */
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Length: ' . $file['size']);
header('Content-Disposition: attachment; filename=' . $file['real_name']);
$open_directly = array(
'pdf',
'jpg',
'jpeg',
'gif',
'png',
'txt',
);
if ( isset($open_directly[strtolower(pathinfo($file['real_name'], PATHINFO_EXTENSION))]) )
{
header('Location: ' . $realpath);
exit();
}
/*
$realpath = $hesk_settings['server_path'].'/attachments/'.$file['saved_name'];
$chunksize = 1 * (1024 * 1024);
if ($file['size'] > $chunksize)
{
$handle = fopen($realpath, 'rb');
$buffer = '';
while ( ! feof($handle))
{
set_time_limit(300);
$buffer = fread($handle, $chunksize);
echo $buffer;
flush();
}
fclose($handle);
}
else
{
readfile($realpath);
}
exit();*/
?>
Re: Open attachments on page.html
My instructions were different: add that piece of code ABOVE (before) the first header line. I did not say other lines need to be commented out.
You should just add my code BEFORE
So it looks like
Do not edit or delete (uncomment) any other part of code.
You should just add my code BEFORE
Code: Select all
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
Code: Select all
$open_directly = array(
'pdf',
'jpg',
'jpeg',
'gif',
'png',
'txt',
);
if ( isset($open_directly[strtolower(pathinfo($file['real_name'], PATHINFO_EXTENSION))]) )
{
header('Location: ' . $realpath);
exit();
}
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: Open attachments on page.html
Many thanks Klemen
My apologies for the lack of attention.
I am evaluating the system and it seems really very interesting.
Many thanks again!
My apologies for the lack of attention.
I am evaluating the system and it seems really very interesting.
Many thanks again!