View Single Post
  #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
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01291 seconds
  • Memory Usage 1,795KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)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 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete