vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Retrieve and display attachments from database (https://vborg.vbsupport.ru/showthread.php?t=189684)

matt3830 09-01-2008 12:09 AM

Retrieve and display attachments from database
 
I'm trying to retrieve the 10 most recent attachments on an outside page. My attachments are in files. This is what I've come up with so far, but I don't know what the path is to the images and how to display them. Any suggestions?

<?php

$result = mysql_query("SELECT * FROM attachment ORDER BY dateline DESC LIMIT 0,10", $connection);
if (!$result) {
die("Database query failed: " . mysql_error());
}

while ($row = mysql_fetch_array($result)) {
echo "<img src=\"/attachmentpath/" . $row[4] . "/><br />";
}
?>

Eikinskjaldi 09-01-2008 12:40 AM

The attachment table will define the type of attachment.

The actual attachments live in

baseaddress/attachments/u/s/r/i/d/attachmentid.attach

The user ID is broken into individual digits as directories, so if you have userid 603 and an attachment id of 500 then it will live in

attachments/6/0/3/500.attach

There is also an attendant 500.thumb

matt3830 09-01-2008 12:53 AM

Thanks, so I have the path, but how do you display .attach?

Dismounted 09-01-2008 06:40 AM

".attach" is just a temporary extension. The content of this ".attach" file is the actual file.

Eikinskjaldi 09-01-2008 10:39 PM

Query the attachment table to see what kind of file it actually is, and then convince php to handle the file correctly. This may involve moving the file to /tmp with the appropriate suffix, or...well...something else. php/file system interactions are not my forte.

Dismounted 09-02-2008 07:49 AM

Basically, you just need to send the correct headers to the browser.


All times are GMT. The time now is 02:26 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01020 seconds
  • Memory Usage 1,713KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete