Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #11  
Old 04-02-2009, 09:52 PM
JamesAB JamesAB is offline
 
Join Date: Dec 2003
Posts: 125
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've been doing a bit more digging and it seems that the POST vars have to be in the form of an object. They can be inline as I had them, or declared earlier. Unfortunately, you can't use a standard string with all the POST information combined here.

My problem is still that I can't use SESSIONURL + 'securitytoken' as the name of variable, since I'm ultimately trying to POST:

Code:
SESSIONURL + 'securitytoken=' + SECURITYTOKEN
The following code is sending vbsessionurlsecuritytoken as the name of the POST variable, not the value of vbsessionurlsecuritytoken.

Code:
// THIS DOES NOT WORK
var vbsessionurlsecuritytoken = "securitytoken";
uploader.upload(fileID, "http://tforum.mydomain.com/uploadzip.php", 
                "POST", 
                {"do":"doupload", 
		"albumid":jababumid, 
		"jabuniquezip":jabuniquezip,
		vbsessionurlsecuritytoken:SECURITYTOKEN}, 
		"upload");
Is it even possible in javascript to create an object where the name of the variable is dynamic?

Thanks,
James
Reply With Quote
  #12  
Old 04-03-2009, 05:05 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try:
Code:
uploader.upload(fileID, 'http://tforum.mydomain.com/uploadzip.php', 'POST', {
	sessionurl: SESSIONURL
	do: 'doupload', 
	albumid: jababumid, 
	jabuniquezip: jabuniquezip,
	securitytoken: SECURITYTOKEN
	}, 'upload'
);
Reply With Quote
  #13  
Old 04-06-2009, 06:48 PM
JamesAB JamesAB is offline
 
Join Date: Dec 2003
Posts: 125
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Dismounted. That appears to be working so far.

Now I'm also looking at using the YUI uploader to allow selecting multiple files (with upload progress bars) for album uploads. In some ways this will be simpler than the original project I had for uploading & adding photos from a .ZIP file.

Looking at the hidden form fields in the album_picture_upload template:

Code:
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input type="hidden" name="do" value="uploadpictures" />
<input type="hidden" name="albumid" value="$albuminfo[albumid]" />
<input type="hidden" name="MAX_FILE_SIZE" value="$inimaxattach" />
It looks like I'll just need to add these to the YUI uploader's POST variables object and set the YUI uploader's URL to use the equivalent of album.php?do=uploadpictures&amp;albumid=$albuminfo[albumid]

Am I correct that these two do the same thing?
Code:
//In the template
<input type="hidden" name="s" value="$session[sessionhash]" />
Code:
//In the javascript uploader POST object
sessionurl: SESSIONURL

This just leaves the javascript not knowing the albumid or MAX_FILE_SIZE, I believe.

Is the best way to pass these variables from PHP to javascript, the way I have been doing it so far?
Code:
<script type="text/javascript">var jababumid = <?php echo $albuminfo['albumid']; ?>;</script> 

<script type="text/javascript">var jabinimaxattach = <?php echo $inimaxattach; ?>;</script>
Thanks for everyone's help,
James
Reply With Quote
  #14  
Old 04-07-2009, 08:03 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by JamesAB View Post
Is the best way to pass these variables from PHP to javascript, the way I have been doing it so far?
It's pretty much the only way to do it. You also know to not depend on MAX_FILE_SIZE, right?
Reply With Quote
Reply

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 On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:52 PM.


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.06952 seconds
  • Memory Usage 2,190KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (7)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete