vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   ask about method for saving attachment on server (https://vborg.vbsupport.ru/showthread.php?t=320933)

sa3eka 11-29-2015 09:44 PM

ask about method for saving attachment on server
 
Hi everyone

I want Ask About method for saving attachments(files) on server ?
I try learn the method .
make folder for every member in Attachments folder and named by number id for member and save file uploaded by member in his foder e.x.
admin have id 1
then will be folder for his files ( attachments/1/ )
the admin upload image ( vb.png)
will saved in his file by id in attachment in data base
the directory will be
(vb/attachments/1/287.attach)

https://vborg.vbsupport.ru/external/2015/11/1.png

that's correct ??

thanks

Dragonsys 11-30-2015 01:27 AM

Basically, but user 111 will have a folder of vb/attachments/1/1/1/123.attach

sa3eka 12-02-2015 12:54 PM

ok bro
But i want programming file(php) make me can get contact the attachment via id user and id attachment ....

how i can get it? if i have 300.000 user in my form

Dragonsys 12-02-2015 02:34 PM

to make sure I am understanding, you want a script which will view an attachment file, in the file system, and return the contact info of the user who posted it?

sa3eka 12-02-2015 09:58 PM

yah :) like
if i have member id is =1 and id for attachment in database is =25

http://site.com/show_attach.php?user=1&attach=25
and sorry for my English language :)

Dragonsys 12-02-2015 11:49 PM

well, the folder structure will always be 1 digit. So you know user #111's attachments will be in folder attachments/1/1/1/files. user #112 will be in attachments/1/1/2/files. user 345 will be in attachments/3/4/5/files etc

user #3000 = attachments/3/0/0/0/files
user #30000 = attachments/3/0/0/0/0/files

you can see that the folders stack.

Try something like this (stolen from Stack Exchange):
PHP Code:

puteveryXcharacters($userid,"/",1);

function 
puteveryXcharacters($str,$wha,$cnt) {
  
$strip false;
  if (
strlen($str) % $cnt == 0) {
    
$strip true;
  }
  
$tmp preg_replace('/(.{'.$cnt.'})/',"$1$wha"$str);
  if (
$strip) {
    
$tmp substr($tmp,0,-1);
  }
  return 
$tmp;


if userid is 123 this should return 1/2/3

NOTE: This has not been tested by me, so use with caution.

sa3eka 12-03-2015 06:57 PM

thank u bro,
I test it,
that work for me
thanx


All times are GMT. The time now is 10:20 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.00990 seconds
  • Memory Usage 1,729KB
  • 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)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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