vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   YUI and vB SESSIONURL question (https://vborg.vbsupport.ru/showthread.php?t=209669)

JamesAB 04-02-2009 09:52 PM

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

Dismounted 04-03-2009 05:05 AM

Try:
Code:

uploader.upload(fileID, 'http://tforum.mydomain.com/uploadzip.php', 'POST', {
        sessionurl: SESSIONURL
        do: 'doupload',
        albumid: jababumid,
        jabuniquezip: jabuniquezip,
        securitytoken: SECURITYTOKEN
        }, 'upload'
);


JamesAB 04-06-2009 06:48 PM

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

Dismounted 04-07-2009 08:03 AM

Quote:

Originally Posted by JamesAB (Post 1785237)
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. :p You also know to not depend on MAX_FILE_SIZE, right?


All times are GMT. The time now is 10:21 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.01118 seconds
  • Memory Usage 1,727KB
  • 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
  • (7)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete