Firefox PHP

3.4.8a Preview and Attachments Problem Solved

Posted by Russ McClay 
3.4.8a Preview and Attachments Problem Solved
November 29, 2005 03:00PM
I ran into a problem with 3.4.8a with Preview and attachments.
What I discovered is that people would write a message and include
an attached file and then hit preview.

In the preview view we see at the top what the message will look
like and below that the post form is displayed again. But the
attachment input fields are now blank. So many users would try
to use those fields again and then post. The result is that
the file would be uploaded but it wouldn't have message id in
the database.

So to fix this problem I simply don't display the file input
boxes in preview mode.


At line 158 in $phorum/include/form.php:

<?php
if ($AllowAttachments && $ForumAllowUploads == 'Y' && $ForumMaxUploads<4) {
for($x=0;$x<$ForumMaxUploads;$x++){
echo "<tr>\n";
echo ' <td height="21" ' . bgcolor($ForumTableBodyColor1) . ' nowrap="nowrap"><font color="' . $ForumTableBodyFontColor1 . '">&nbsp;' . $lFormAttachment . ':</font></td>';
echo ' <td height="21" ' . bgcolor($ForumTableBodyColor1) . '><input type="File" name="attachment_'.$x.'" size="30" maxlength="64" tabindex="4"></td>';
echo "</tr>\n";
}
}
?>


I changed to:

<?php

if(!$preview){

if ($AllowAttachments && $ForumAllowUploads == 'Y' && $ForumMaxUploads<4) {
for($x=0;$x<$ForumMaxUploads;$x++){
echo "<tr>\n";
echo ' <td height="21" ' . bgcolor($ForumTableBodyColor1) . ' nowrap="nowrap"><font color="' . $ForumTableBodyFontColor1 . '">&nbsp;' . $lFormAttachment . ':</font></td>';
echo ' <td height="21" ' . bgcolor($ForumTableBodyColor1) . '><input type="File" name="attachment_'.$x.'" size="30" maxlength="64" tabindex="4"></td>';
echo "</tr>\n";
}
}

}

?>

*******************************************************************
The only change is the first and last line; just wrap the simple
clause with:

if(!$preview){
...
}



I searched high and low in the forums here for a question or answer to this.

Russ



Edited 1 time(s). Last edit at 11/29/2005 03:04PM by Russ McClay.
Re: 3.4.8a Preview and Attachments Problem Solved
November 30, 2005 12:30PM
For security reasons, a server script cannot set the initial value for the file selection box. So it's impossible to keep that field intact during preview. Therefore the preview screen loses the attachment. You can hide the file selection in preview, but then you still loose the attachment. All that your users can do right now, is first look at the preview and from there add the attachment before posting.

For being able to use preview in combination with file attachments, totally new software has to be written. This has been done for Phorum 5. So if you want to have better attachment functionality, then you'll have to upgrade your Phorum installation.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, you do not have permission to post/reply in this forum.