vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Making a custom multiple attachment upload script (https://vborg.vbsupport.ru/showthread.php?t=262700)

jwocky 04-26-2011 11:57 PM

Making a custom multiple attachment upload script
 
After searching and searching, I cannot find a mod which will allow multiple file uploads for vb3.

I decided to make my own one then, there are plenty of jquery/mootools based scripts for multiple file uploads (basicly highlight 10 files in a directory and upload them each sequentially automatically).

My problem arises from the basics of integrating this to vbulletin. I first researched how to get those uploads into the database using a datamanager, but while reading through newattachment.php it struck me that maybee its best to have my script take the uploaded files and simply feed them into the stock vbulletin newattachment.php and let vb attach the files to the post as it normally does.

My question is this, does anyone know the exact data that needs to be POSTed to newattachment.php to get an attachment into a post?

thanks!!!!

kh99 04-27-2011 01:22 AM

If you edit a post then press the Attachments button to bring up that popup, then do "View Source" on that popup window, I think it might have everything you need.

jwocky 04-27-2011 10:04 PM

Quote:

Originally Posted by kh99 (Post 2189110)
If you edit a post then press the Attachments button to bring up that popup, then do "View Source" on that popup window, I think it might have everything you need.

Yea im trying to do just that, I took all the variables in the form submission, put them into my custom html and tried submitting from my custom php file and it just wont take. I cant wrap my head around the issue...

Here is what I have:

PHP Code:

<form enctype="multipart/form-data" action="newattachment.php?do=manageattach&amp;p=1982" name="newattachment" method="post">
<
input type="hidden" name="s" value="" />
<
input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]/>
<
input type="hidden" name="do" value="manageattach" />
<
input type="hidden" name="t" value="208" />
<
input type="hidden" name="f" value="2" />
<
input type="hidden" name="p" value="1982" />
<
input type="hidden" name="poststarttime" value="1303943857" />
<
input type="hidden" name="editpost" value="1" />
<
input type="hidden" name="posthash" value="2608dd6db75e2c448ee70aa358eab0a3" />
            
<
fieldset class="fieldset">
<
input type="hidden" name="MAX_FILE_SIZE" value="33554432" />
<
input type="file" class="bginput" name="attachment[]" size="30" /><br />
<
input type="file" class="bginput" name="attachment[]" size="30" /><br />
<
input type="submit" class="button" name="upload" value="Upload" style="width:70px"/></td>
</
fieldset>
</
form

I manually put in all the values to match up with my test thread, except for the session hash which im letting vb fill in

kh99 04-27-2011 10:47 PM

Just glancing at it the only thing I see maybe is this line:

Code:

<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />

you probably need the actual value of the security token in there. When it's in a template it gets 'eval'ed and the value of $bbuserinfo[securitytoken] is inserted, but if you're not doing that in your custom code then you'll have to do it yourself.

Also, IIRC the code for that popup has a javascript function that gets called when the form is submitted which handles the actual file data (in some way I don't really understand, so maybe you've got that covered somewhere else).

jwocky 04-27-2011 10:51 PM

Quote:

Originally Posted by kh99 (Post 2189454)
Just glancing at it the only thing I see maybe is this line:

Code:

<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />

you probably need the actual value of the security token in there. When it's in a template it gets 'eval'ed and the value of $bbuserinfo[securitytoken] is inserted, but if you're not doing that in your custom code then you'll have to do it yourself.

Also, IIRC the code for that popup has a javascript function that gets called when the form is submitted which handles the actual file data (in some way I don't really understand, so maybe you've got that covered somewhere else).

Ya, i checked and made sure that the data is being filled in correctly by vb (it is), you are right about the javascript, i couldnt figure out what it was doing so i skipped it (i *think* it was just allowing the text 'Uploading...' to display while the upload is going, i dont think it was doing anything real so i decided to chop it out. This is frustrating :)

kh99 04-27-2011 11:00 PM

Quote:

Originally Posted by jwocky (Post 2189457)
(i *think* it was just allowing the text 'Uploading...' to display while the upload is going, i dont think it was doing anything real so i decided to chop it out.

I just looked again and I think you're right about that. I guess I'll stop "helping" you since you seem to understand it better than I do. :)

jwocky 04-28-2011 09:03 PM

Quote:

Originally Posted by kh99 (Post 2189459)
I just looked again and I think you're right about that. I guess I'll stop "helping" you since you seem to understand it better than I do. :)

Not at all, I really appreciate the effort, I still think im more lost then you are, but both lost :D

kh99 04-28-2011 09:18 PM

So what does happen when you try? Do you get an error or just nothing?


All times are GMT. The time now is 02:44 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.01143 seconds
  • Memory Usage 1,750KB
  • 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
  • (2)bbcode_code_printable
  • (1)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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