vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Can someone tell me what's not working in this code snippet? (https://vborg.vbsupport.ru/showthread.php?t=169320)

styleforum 02-01-2008 03:44 AM

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.

Lynne 02-01-2008 02:39 PM

Do you realize you don't have $target_encoding defined in the second one (like you do in the first)?

styleforum 02-01-2008 03:46 PM

Quote:

Originally Posted by Lynne (Post 1433977)
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.

Lynne 02-01-2008 03:54 PM

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.

styleforum 02-02-2008 06:20 AM

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.


All times are GMT. The time now is 09:14 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.00981 seconds
  • Memory Usage 1,738KB
  • 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
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete