View Full Version : Making a custom multiple attachment upload script
jwocky
04-26-2011, 11:57 PM
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!!!!
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
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:
<form enctype="multipart/form-data" action="newattachment.php?do=manageattach&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
Just glancing at it the only thing I see maybe is this line:
<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
Just glancing at it the only thing I see maybe is this line:
<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 :)
(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
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
So what does happen when you try? Do you get an error or just nothing?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.