Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-17-2007, 04:57 PM
dgeere dgeere is offline
 
Join Date: Nov 2007
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help Passing Vbulletin Variables to and back from another php script

I am trying to remove users having to use FTP to get large / many files up onto the website and into photopost.

I have finished working with the jumploader bulk upload script so that it can upload files to the user directory instead of having to use FTP.

I just need some final help from anyone on submitting the upload to the usual bulk upload script of photopost in order to continue the process. Any help would be amazing as I am stuck on this last bit!

Here is what I need to sort:
- Send selected category / gallery and current vbulletin userid as variables to the php / java upload page

- Let them upload their files

- Once upload completes, take user to next step in bulk upload page with their category chosen.


For reference here is the code I am using on my image upload page using the jumploader from
http://www.jumploader.com/documentation.html


Theses are my files:

Page containing uploader:

Code:
<?
ini_set("post_max_size","900M");
ini_set("upload_max_filesize","900M");


?>
<html>
<head>
</head>
<body>
<div style="width: 600px;">

<B>Step 1:</B> Browse for the folder containing your photos<BR>
 &nbsp;  &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;- The folder must ONLY contain image files. Anything else will cause problems<BR>
<B>Step 2:</B> Drag the folder over to the "drop files here" area<BR>
<B>Step 3:</B> Click that large UP arrow at the bottom to upload the files<BR>
<B>Step 4:</B> Have a drink while everything uploads<BR>
<B>Step 5:</B> Once everything has <B>uploaded 100%</b> you can then close this window and continue<BR><BR>
</div>
<div>
<applet name="jumpLoaderApplet"
		code="jmaster.jumploader.app.JumpLoaderApplet.class"
		archive="jumploader_z.jar"
		width="650"
		height="500" 
		mayscript>

<param name="uc_uploadUrl" value="/upload/uploadHandler.php?uid=<?php echo $_GET["id"]; ?>"/>
<param name="uc_directoriesEnabled" value="true"/> 
<param name="uc_partitionLength" value="1048576"/> 

         <param name="vc_fileTreeViewShowFiles" value="false"/>
         <param name="vc_mainViewFileListViewVisible" value="false"/>
         <param name="vc_fileListViewLocationBarVisible" value="false"/> 
  <param name="vc_uploadViewAddActionVisible" value="false"/>
  <param name="vc_uploadViewMenuBarVisible" value="false"/>


</applet>

</div>
</body>
</html>


<?
?>



The upload handler with partitioning:

Code:
<?php
ini_set("post_max_size","900M");
ini_set("upload_max_filesize","900M");
$uidhope = $_GET['uid']; 
//----------------------------------------------
//    partitioned upload file handler script
//----------------------------------------------

//
//    specify upload directory - storage
//    for reconstructed uploaded files
$upload_dir = "/home/fhlinux159/s/user/htdocs/photos/users/" . $uidhope . "/";

//
//    specify stage directory - temporary storage
//    for uploaded partitions
$stage_dir = "/home/fhlinux159/s/user/htdocs/upload/stage/";

//
//    retrieve request parameters
$file_param_name = 'file';
$file_name = $_FILES[ $file_param_name ][ 'name' ];
$file_id = $_POST[ 'fileId' ];
$partition_index = $_POST[ 'partitionIndex' ];
$partition_count = $_POST[ 'partitionCount' ];
$file_length = $_POST[ 'fileLength' ];

//
//    the $client_id is an essential variable,
//    this is used to generate uploaded partitions file prefix,
//    because we can not rely on 'fileId' uniqueness in a
//    concurrent environment - 2 different clients (applets)
//    may submit duplicate fileId. thus, this is responsibility
//    of a server to distribute unique clientId values
//    (or other variable, for example this could be session id)
//    for instantiated applets.
$client_id = $_GET[ 'clientId' ];

//
//    move uploaded partition to the staging folder
//    using following name pattern:
//    ${clientId}.${fileId}.${partitionIndex}
$source_file_path = $_FILES[ $file_param_name ][ 'tmp_name' ];
$target_file_path = $stage_dir . $client_id . "." . $file_id .
    "." . $partition_index;
if( !move_uploaded_file( $source_file_path, $target_file_path ) ) {
    echo "Error:Can't move uploaded file";
    return;
}

//
//    check if we have collected all partitions properly
$all_in_place = true;
$partitions_length = 0;
for( $i = 0; $all_in_place && $i < $partition_count; $i++ ) {
    $partition_file = $stage_dir . $client_id . "." . $file_id . "." . $i;
    if( file_exists( $partition_file ) ) {
        $partitions_length += filesize( $partition_file );
    } else {
        $all_in_place = false;
   echo "problem with partitions";
    }
}

//
//    issue error if last partition uploaded, but partitions validation failed
if( $partition_index == $partition_count - 1 &&
        ( !$all_in_place || $partitions_length != intval( $file_length ) ) ) {
    echo "Error:Upload validation error";
    return;
}

//
//    reconstruct original file if all ok
if( $all_in_place ) {
    //$file = $upload_dir . $client_id . "." . $file_id;
$file = $upload_dir . $client_id . $file_name;
    $file_handle = fopen( $file, 'a' );
    for( $i = 0; $all_in_place && $i < $partition_count; $i++ ) {
        //
        //    read partition file
        $partition_file = $stage_dir . $client_id . "." . $file_id . "." . $i;
        $partition_file_handle = fopen( $partition_file, "rb" );
        $contents = fread( $partition_file_handle, filesize( $partition_file ) );
        fclose( $partition_file_handle );
        //
        //    write to reconstruct file
        fwrite( $file_handle, $contents );
        //
        //    remove partition file
        unlink( $partition_file );
    }
    fclose( $file_handle );
} ?>
<html>
<body>
	<h1>GET content</h1>
	<pre><?print_r( $_GET );?></pre>
	<h1>POST content</h1>
	<pre><?print_r( $_POST );?></pre>
	<h1>FILES content</h1>
	<pre><?print_r( $_FILES );?></pre>
</body>
--------------- Added [DATE]1195327384[/DATE] at [TIME]1195327384[/TIME] ---------------

Crap, can someone move this to programming as I don't want to dupe post... ?
Reply With Quote
Reply


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 09:00 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03586 seconds
  • Memory Usage 2,177KB
  • 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
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete