Current location: Hot Scripts Forums » Programming Languages » PHP » attachment help


attachment help

Reply
  #1 (permalink)  
Old 07-09-04, 07:12 AM
steveo steveo is offline
Wannabe Coder
 
Join Date: Jun 2004
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
Arrow attachment help

I recently installed a forum, and to make the forum fit nicly into my website i had to active something that stops users attachments being displayed on the forum, as it creates the froum to go alot bigger.
What i wanted it to do was to display a link to the attachment and show it. Well it seems to want people to download it insted.

I am wondering if anyone can edit the below code to it will display the attachment in this page insted of trying to download it.

PHP Code:

<?php

include("connect.php");
include(
"necessary/zero.php");
include(
"necessary/first.php");
logincontrol($tblname_user);
include(
"necessary/third.php");

$resultupload mysql_query("SELECT * FROM $tblname_attach WHERE attach_id='$id'");
  
$attachid mysql_result($resultupload,0,"attach_id");
  
$attachname mysql_result($resultupload,0,"attach_name");
  
$attachfile $attachid."_".$attachname;
  
$attachurl="files/$attachfile";

if (
$down!="ne"mysql_query("UPDATE $tblname_attach SET attach_download=attach_download+1 WHERE attach_id='$id'");

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=$attachname");
header("Content-Transfer-Encoding: binary");
header("Expires: 0");
header("Pragma: no-cache");
@
readfile($attachurl);
exit();
?>
The above code was on a .php file called attach.php
Reply With Quote
  #2 (permalink)  
Old 07-09-04, 11:37 PM
kvnband kvnband is offline
Wannabe Coder
 
Join Date: Jun 2003
Posts: 242
Thanks: 0
Thanked 0 Times in 0 Posts
I'm not totally sure, but try removing

PHP Code:

header("Content-Disposition: attachment; filename=$attachname"); 

I've read somewhere that if you want to force download, you use that code. So maybe removing it will stop the force download
Kevin

PS..let me know if that's what it was
Reply With Quote
  #3 (permalink)  
Old 07-10-04, 05:42 AM
steveo steveo is offline
Wannabe Coder
 
Join Date: Jun 2004
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
Yes! Thank you very much. You don't know what this will do to me, it means alot!
It worked!

Thank you once again.
Reply With Quote
  #4 (permalink)  
Old 07-10-04, 08:38 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
I think it's better to remove all header()s from there as they are all regarding download ..
but I am not sure tho ..
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
mail ( ) + attachment rsuresh PHP 1 06-16-04 09:26 AM
attachment script for phpbb forum musiq PHP 1 06-10-04 12:29 PM
MIME Attachment for Email Form phpuser PHP 0 12-10-03 01:15 PM


All times are GMT -5. The time now is 05:09 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.