PDA

View Full Version : attachment viewing..


JediKNight
04-07-2002, 02:06 AM
I think of a small modification (since I am very new to PHP, i don't want to call it a hack yet :D) to let user view the attachment nicely on a page with a layout..
I commented out the if at the end of attachment.php and the echo command, to insert this:


header("Content-type:text/html");

$pointer=fopen("$attachmentinfo[filename]", "a+");
fwrite ($pointer,$attachmentinfo[filedata]);
fclose($pointer);

print <<<END
You're viewing attachment from $bbtitle
<img src="$attachmentinfo[filename]">
END;


but it took the server too long to write the file and show the html with the picture.. and guess what.. the image actually showed up but was totally corrupted.. so bad that was beyond recognization..

there is no way to overcome that?

Jedi

Admin
04-07-2002, 10:46 AM
I wrote this kind of hack, check it out "Attachment Viewer". You can just link to attachment.php?attachmentid=XX to view the image, but you also need to make sure you don't output the HTML twice. :)

JediKNight
04-07-2002, 01:58 PM
FireFly, thank you for your speedy reply.

My idea of attachment viewing is slightly different from your solution.

I would like to WRITE the $attachmentinfo[filedata] into an image file on the server, then serve the user a page in HTML to show that image (with <img..> tags), this way we can create a new template to have a better attachment viewing experience for user, and better advertising for our forums..
We will be also able to let them know where are they watching the image... (In case someone links attachment in our forum to other places.)

but I don't know why the fwrite() tooks so long to finish, and the newly written file is totally corrupted.. I think fwrite() is binary safe?

my board is 2.2.4 and I am testing with 2.2.4

Jedi