Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

problems with file uploads

ThemisThemis Member Posts: 73
I 'm trying to upload a file in my site using php unfortunately without any luck. I 'm using the following form:

[code]



[/code]

in my php code I catch the submit event and the I call a function doing the following:

[code]
// file uploading //////////////////////
$uploaddir = $submit[3];
if (strrpos($uploaddir, "/") != strlen($uploaddir) -1)
$uploaddir = $uploaddir . "/";
$uploadfile = $uploaddir . $username;

print_r($_FILES);

if (move_uploaded_file($_FILES[$file]['tmp_name'], $uploadfile))
{
$text = $text . "File is valid, and was successfully uploaded.";
$text = $text . "Here's some more debugging info:
";
print_r($_FILES);
} else
{
$text = $text . "Possible file upload attack! Here's some debugging info:
";
print_r($_FILES);
}
[/code]

The code is from an example in php manual. You may ignore the first few line where I get some data from field (this is a part of my code anyway). The case is that the print_r() function doesn't print anything (just: Array()). Shouldn't it have information about my upload? As you may imagine on my screen I get the second message about upload attack. Am I doing sth wrong? Do I have to do anything else in order to make an upload?

Thank you, Themis

Comments

  • skylarskylar Member Posts: 82
    : I 'm trying to upload a file in my site using php unfortunately without any luck. I 'm using the following form:
    :
    : [code]
    :
    :
    :
    : : :

    :
    :
    :
    :
    : [/code]
    :
    : in my php code I catch the submit event and the I call a function doing the following:
    :
    : [code]
    : // file uploading //////////////////////
    : $uploaddir = $submit[3];
    : if (strrpos($uploaddir, "/") != strlen($uploaddir) -1)
    : $uploaddir = $uploaddir . "/";
    : $uploadfile = $uploaddir . $username;
    :
    : print_r($_FILES);
    :
    : if (move_uploaded_file($_FILES[$file]['tmp_name'], $uploadfile))
    : {
    : $text = $text . "File is valid, and was successfully uploaded.";
    : $text = $text . "Here's some more debugging info:
    ";
    : print_r($_FILES);
    : } else
    : {
    : $text = $text . "Possible file upload attack! Here's some debugging info:
    ";
    : print_r($_FILES);
    : }
    : [/code]
    :
    : The code is from an example in php manual. You may ignore the first few line where I get some data from field (this is a part of my code anyway). The case is that the print_r() function doesn't print anything (just: Array()). Shouldn't it have information about my upload? As you may imagine on my screen I get the second message about upload attack. Am I doing sth wrong? Do I have to do anything else in order to make an upload?
    :
    : Thank you, Themis
    :



    Try doing this:

    foreach($_FILES as $fname1=>$f1){
    if(is_array($f1)){
    echo "Array Contents : $fname1
    ";
    foreach($f1 as $fname2=>$f2){
    echo "  $fname2 : $f2
    ";
    }
    }
    else{
    echo "  $fname1 : $f1";
    }
    }

    It might show the results you want.. i don't know why your print_r isn't working..
    [b][blue]Snoochie Boochies[/blue][/b]

Sign In or Register to comment.