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 02-01-2008, 03:44 AM
styleforum styleforum is offline
 
Join Date: Jun 2005
Posts: 72
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Can someone tell me what's not working in this code snippet?

I'm having some trouble working from a hardcoded version of this to one that will take a userid and work for everyone. It's the upload script after a flash batch uploader. What I have right now is that the first version works fine, but something is wrong with my syntax (I think, I'm really not a programmer, as you can probably tell) that's keeping the second one from writing the files to the directory they go in. The function check_user_dir looks for a directory corresponding to $uploaduser, and makes one if it's not there. That is working in both versions. It makes a directory called ./uploads/20, and chmods it 777, which is what I need for the next part. Then it doesn't upload the files into that directory. I don't know how to check where it's breaking. I'm guessing it's somewhere in the declaration of $uploaddir, because I don't know how to make a path with all this stuff in it and I can't find a similar example.

Later, I'll figure out how to pass the actual userid to $uploaduser, but for right now I just set it to eliminate that as a problem.

I'd really appreciate any help.

This script works:

PHP Code:
$uploaddir dirname($_SERVER['SCRIPT_FILENAME'])."/uploads/425/";

$target_encoding "ISO-8859-1";
echo 
'<pre>';
if(
count($_FILES) > 0)
{
    
$arrfile pos($_FILES);
    
$uploadfile $uploaddir iconv("UTF-8"$target_encoding,basename($arrfile['name']));

    if (
move_uploaded_file($arrfile['tmp_name'], $uploadfile))
       echo 
"File is valid, and was successfully uploaded.\n";
}
else
    echo 
'No files sent. Script is OK!'//Say to Flash that script exists and can receive files

echo 'Here is some more debugging info:';
print_r($_FILES);

echo 
"</pre>"
This one almost does:

PHP Code:
$uploaduser "20"// testing - remove later

$uploaddir dirname($_SERVER['SCRIPT_FILENAME']). "/uploads/" $uploaduser "/";

check_user_dir $uploaduser );

echo 
'<pre>';
if(
count($_FILES) > 0)
{
    
$arrfile pos($_FILES);
    
$uploadfile $uploaddir iconv("UTF-8"$target_encoding,basename($arrfile['name']));

    if (
move_uploaded_file($arrfile['tmp_name'], $uploadfile))
       echo 
"File is valid, and was successfully uploaded.\n";
}
else
    echo 
'No files sent. Script is OK!'//Say to Flash that script exists and can receive files

echo 'Here is some more debugging info:';
print_r($_FILES); 
Thanks.

--------------- Added [DATE]1201845480[/DATE] at [TIME]1201845480[/TIME] ---------------

Okay, I had it echo $uploaddir and it gives me the right directory, so that declaration is working.
Reply With Quote
  #2  
Old 02-01-2008, 02:39 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Do you realize you don't have $target_encoding defined in the second one (like you do in the first)?
Reply With Quote
  #3  
Old 02-01-2008, 03:46 PM
styleforum styleforum is offline
 
Join Date: Jun 2005
Posts: 72
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
Do you realize you don't have $target_encoding defined in the second one (like you do in the first)?
Sorry, I cut and pasted badly, but it was just above the section I pasted. I later rearranged that so it's more in the order of the working one, but it still doesn't work.

Thanks.
Reply With Quote
  #4  
Old 02-01-2008, 03:54 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Have you checked your error_logs to see if there are any errors in there? I know when I was working with upload code on my site, that was often the only place I could go to get feedback.
Reply With Quote
  #5  
Old 02-02-2008, 06:20 AM
styleforum styleforum is offline
 
Join Date: Jun 2005
Posts: 72
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks.

As it turned out, an include above all that, in the second one, called to something that unset $_FILES, so it was skipping the whole upload part. I've got it working now.
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 01:25 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.03331 seconds
  • Memory Usage 2,215KB
  • 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_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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_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